<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="generator" content="quarto-1.7.32">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Model Summaries – modelsummary: Data and Model Summaries in R</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
  width: 0.8em;
  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
  vertical-align: middle;
}
/* CSS for syntax highlighting */
html { -webkit-text-size-adjust: 100%; }
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
  }
pre.numberSource { margin-left: 3em;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
</style>

<script src="../site_libs/quarto-nav/quarto-nav.js"></script>
<script src="../site_libs/quarto-nav/headroom.min.js"></script>
<script src="../site_libs/clipboard/clipboard.min.js"></script>
<script src="../site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="../site_libs/quarto-search/fuse.min.js"></script>
<script src="../site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="../">
<link href="../vignettes/modelplot.html" rel="next">
<link href="../vignettes/datasummary.html" rel="prev">
<script src="../site_libs/quarto-html/quarto.js" type="module"></script>
<script src="../site_libs/quarto-html/tabsets/tabsets.js" type="module"></script>
<script src="../site_libs/quarto-html/popper.min.js"></script>
<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="../site_libs/quarto-html/anchor.min.js"></script>
<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="../site_libs/quarto-html/quarto-syntax-highlighting-37eea08aefeeee20ff55810ff984fec1.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="../site_libs/bootstrap/bootstrap.min.js"></script>
<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="../site_libs/bootstrap/bootstrap-555d7fa6eb067a0c9d334ac7ef1a20f4.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light"><script id="quarto-search-options" type="application/json">{
  "location": "navbar",
  "copy-button": false,
  "collapse-after": 3,
  "panel-placement": "end",
  "type": "overlay",
  "limit": 50,
  "keyboard-shortcut": [
    "f",
    "/",
    "s"
  ],
  "show-item-context": false,
  "language": {
    "search-no-results-text": "No results",
    "search-matching-documents-text": "matching documents",
    "search-copy-link-title": "Copy link to search",
    "search-hide-matches-text": "Hide additional matches",
    "search-more-match-text": "more match in this document",
    "search-more-matches-text": "more matches in this document",
    "search-clear-button-title": "Clear",
    "search-text-placeholder": "",
    "search-detached-cancel-button-title": "Cancel",
    "search-submit-button-title": "Submit",
    "search-label": "Search"
  }
}</script><script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script><script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script><script type="text/javascript">
const typesetMath = (el) => {
  if (window.MathJax) {
    // MathJax Typeset
    window.MathJax.typeset([el]);
  } else if (window.katex) {
    // KaTeX Render
    var mathElements = el.getElementsByClassName("math");
    var macros = [];
    for (var i = 0; i < mathElements.length; i++) {
      var texText = mathElements[i].firstChild;
      if (mathElements[i].tagName == "SPAN") {
        window.katex.render(texText.data, mathElements[i], {
          displayMode: mathElements[i].classList.contains('display'),
          throwOnError: false,
          macros: macros,
          fleqn: false
        });
      }
    }
  }
}
window.Quarto = {
  typesetMath
};
</script>
</head>
<body class="nav-sidebar floating nav-fixed quarto-light">

<div id="quarto-search-results"></div>
  <header id="quarto-header" class="headroom fixed-top"><nav class="navbar navbar-expand-lg " data-bs-theme="dark"><div class="navbar-container container-fluid">
      <div class="navbar-brand-container mx-auto">
    <a class="navbar-brand" href="../index.html">
    <span class="navbar-title">modelsummary: Data and Model Summaries in R</span>
    </a>
  </div>
            <div id="quarto-search" class="" title="Search"></div>
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" role="menu" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
  <span class="navbar-toggler-icon"></span>
</button>
          <div class="collapse navbar-collapse" id="navbarCollapse">
            <ul class="navbar-nav navbar-nav-scroll ms-auto">
<li class="nav-item">
    <a class="nav-link active" href="../vignettes/get_started.html" aria-current="page"> 
<span class="menu-text">Get started</span></a>
  </li>  
  <li class="nav-item compact">
    <a class="nav-link" href="https://github.com/vincentarelbundock/modelsummary/"> <i class="bi bi-github" role="img" aria-label="modelsummary GitHub">
</i> 
<span class="menu-text"></span></a>
  </li>  
</ul>
</div> <!-- /navcollapse -->
            <div class="quarto-navbar-tools">
</div>
      </div> <!-- /container-fluid -->
    </nav><nav class="quarto-secondary-nav"><div class="container-fluid d-flex">
      <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
        <i class="bi bi-layout-text-sidebar-reverse"></i>
      </button>
        <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../vignettes/modelsummary.html">Model Summaries</a></li></ol></nav>
        <a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">      
        </a>
    </div>
  </nav></header><!-- content --><div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar">
<!-- sidebar -->
  <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto"><div class="sidebar-menu-container"> 
    <ul class="list-unstyled mt-1">
<li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../vignettes/get_started.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Getting started</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../vignettes/datasummary.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Data Summaries</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../vignettes/modelsummary.html" class="sidebar-item-text sidebar-link active">
 <span class="menu-text">Model Summaries</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../vignettes/modelplot.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Model Plots</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../vignettes/modelsummary_extension.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Custom</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../vignettes/appearance.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Themes and Styles</span></a>
  </div>
</li>
        <li class="sidebar-item sidebar-item-section">
      <div class="sidebar-item-container"> 
            <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="false">
 <span class="menu-text">Functions</span></a>
          <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="false" aria-label="Toggle section">
            <i class="bi bi-chevron-right ms-2"></i>
          </a> 
      </div>
      <ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 ">
<li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/modelsummary.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>modelsummary</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/modelplot.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>modelplot</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/datasummary.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>datasummary</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/datasummary_skim.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>datasummary_skim</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/datasummary_balance.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>datsummary_balance</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/datasummary_crosstab.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>datasummary_crosstab</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/datasummary_correlation.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>datasummary_correlation</code></span></a>
  </div>
</li>
          <li class="sidebar-item sidebar-item-section">
      <div class="sidebar-item-container"> 
            <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" role="navigation" aria-expanded="false">
 <span class="menu-text">Formatting</span></a>
          <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" role="navigation" aria-expanded="false" aria-label="Toggle section">
            <i class="bi bi-chevron-right ms-2"></i>
          </a> 
      </div>
      <ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth2 ">
<li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_decimal.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_decimal</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_equivalence.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_equivalence</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_sci.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_sci</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_significant.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_significant</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_sprintf.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_sprintf</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_statistic.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_statistic</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/fmt_term.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>fmt_term</code></span></a>
  </div>
</li>
      </ul>
</li>
          <li class="sidebar-item sidebar-item-section">
      <div class="sidebar-item-container"> 
            <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" role="navigation" aria-expanded="false">
 <span class="menu-text">Utilities</span></a>
          <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" role="navigation" aria-expanded="false" aria-label="Toggle section">
            <i class="bi bi-chevron-right ms-2"></i>
          </a> 
      </div>
      <ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth2 ">
<li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/get_estimates.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>get_estimates</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/get_gof.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>get_gof</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/coef_rename.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>coef_rename</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/dvnames.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>dvnames</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/gof_map.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>gof_map</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/datasummary_correlation_format.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>datasummary_correlation_format</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/config_modelsummary.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>config_modelsummary</code></span></a>
  </div>
</li>
          <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../man/update_modelsummary.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text"><code>update_modelsummary</code></span></a>
  </div>
</li>
      </ul>
</li>
      </ul>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../NEWS.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">News</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../LICENSE.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">License</span></a>
  </div>
</li>
        <li class="sidebar-item">
  <div class="sidebar-item-container"> 
  <a href="../CITATION.html" class="sidebar-item-text sidebar-link">
 <span class="menu-text">Citation</span></a>
  </div>
</li>
    </ul>
</div>
</nav><div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
    <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
        <nav id="TOC" role="doc-toc" class="toc-active"><h2 id="toc-title">On this page</h2>
   
  <ul>
<li><a href="#output" id="toc-output" class="nav-link active" data-scroll-target="#output"><code>output</code></a></li>
  <li><a href="#fmt" id="toc-fmt" class="nav-link" data-scroll-target="#fmt"><code>fmt</code></a></li>
  <li><a href="#estimate" id="toc-estimate" class="nav-link" data-scroll-target="#estimate"><code>estimate</code></a></li>
  <li><a href="#statistic" id="toc-statistic" class="nav-link" data-scroll-target="#statistic"><code>statistic</code></a></li>
  <li><a href="#vcov" id="toc-vcov" class="nav-link" data-scroll-target="#vcov"><code>vcov</code></a></li>
  <li><a href="#stars" id="toc-stars" class="nav-link" data-scroll-target="#stars"><code>stars</code></a></li>
  <li><a href="#coef_omit" id="toc-coef_omit" class="nav-link" data-scroll-target="#coef_omit"><code>coef_omit</code></a></li>
  <li><a href="#coef_rename" id="toc-coef_rename" class="nav-link" data-scroll-target="#coef_rename"><code>coef_rename</code></a></li>
  <li><a href="#coef_map" id="toc-coef_map" class="nav-link" data-scroll-target="#coef_map"><code>coef_map</code></a></li>
  <li><a href="#gof_omit" id="toc-gof_omit" class="nav-link" data-scroll-target="#gof_omit"><code>gof_omit</code></a></li>
  <li><a href="#gof_map" id="toc-gof_map" class="nav-link" data-scroll-target="#gof_map"><code>gof_map</code></a></li>
  <li><a href="#gof_function" id="toc-gof_function" class="nav-link" data-scroll-target="#gof_function"><code>gof_function</code></a></li>
  <li>
<a href="#shape" id="toc-shape" class="nav-link" data-scroll-target="#shape"><code>shape</code></a>
  <ul class="collapse">
<li><a href="#formula" id="toc-formula" class="nav-link" data-scroll-target="#formula">Formula</a></li>
  <li><a href="#string-rbind-or-rcollapse-panels-of-models-in-stacked-regression-tables" id="toc-string-rbind-or-rcollapse-panels-of-models-in-stacked-regression-tables" class="nav-link" data-scroll-target="#string-rbind-or-rcollapse-panels-of-models-in-stacked-regression-tables">String (“rbind” or “rcollapse”): Panels of models in stacked regression tables</a></li>
  <li><a href="#string-cbind-automatic-spanning-column-labels" id="toc-string-cbind-automatic-spanning-column-labels" class="nav-link" data-scroll-target="#string-cbind-automatic-spanning-column-labels">String (“cbind”): Automatic spanning column labels</a></li>
  <li>
<a href="#renaming-estimates-and-statistics" id="toc-renaming-estimates-and-statistics" class="nav-link" data-scroll-target="#renaming-estimates-and-statistics">Renaming estimates and statistics</a>
  <ul class="collapse">
<li><a href="#fixest" id="toc-fixest" class="nav-link" data-scroll-target="#fixest"><code>fixest</code></a></li>
  </ul>
</li>
  </ul>
</li>
  <li><a href="#align" id="toc-align" class="nav-link" data-scroll-target="#align"><code>align</code></a></li>
  <li><a href="#notes" id="toc-notes" class="nav-link" data-scroll-target="#notes"><code>notes</code></a></li>
  <li><a href="#title" id="toc-title" class="nav-link" data-scroll-target="#title"><code>title</code></a></li>
  <li><a href="#add_rows" id="toc-add_rows" class="nav-link" data-scroll-target="#add_rows"><code>add_rows</code></a></li>
  <li><a href="#exponentiate" id="toc-exponentiate" class="nav-link" data-scroll-target="#exponentiate"><code>exponentiate</code></a></li>
  <li>
<a href="#additional-arguments" id="toc-additional-arguments" class="nav-link" data-scroll-target="#additional-arguments"><code>...</code> Additional arguments</a>
  <ul class="collapse">
<li><a href="#reference-categories" id="toc-reference-categories" class="nav-link" data-scroll-target="#reference-categories">Reference categories</a></li>
  <li><a href="#standardization" id="toc-standardization" class="nav-link" data-scroll-target="#standardization">Standardization</a></li>
  </ul>
</li>
  <li><a href="#math" id="toc-math" class="nav-link" data-scroll-target="#math">Math</a></li>
  <li><a href="#themes-and-styles" id="toc-themes-and-styles" class="nav-link" data-scroll-target="#themes-and-styles">Themes and styles</a></li>
  <li><a href="#supported-models" id="toc-supported-models" class="nav-link" data-scroll-target="#supported-models">Supported models</a></li>
  <li>
<a href="#rmarkdown-quarto-org-mode" id="toc-rmarkdown-quarto-org-mode" class="nav-link" data-scroll-target="#rmarkdown-quarto-org-mode">Rmarkdown, Quarto, Org-Mode</a>
  <ul class="collapse">
<li><a href="#rmarkdown" id="toc-rmarkdown" class="nav-link" data-scroll-target="#rmarkdown">Rmarkdown</a></li>
  <li><a href="#quarto" id="toc-quarto" class="nav-link" data-scroll-target="#quarto">Quarto</a></li>
  <li><a href="#emacs-org-mode" id="toc-emacs-org-mode" class="nav-link" data-scroll-target="#emacs-org-mode">Emacs Org-Mode</a></li>
  </ul>
</li>
  <li><a href="#sec-global-options" id="toc-sec-global-options" class="nav-link" data-scroll-target="#sec-global-options">Global options</a></li>
  <li>
<a href="#case-studies" id="toc-case-studies" class="nav-link" data-scroll-target="#case-studies">Case studies</a>
  <ul class="collapse">
<li><a href="#collapse-control-variables-into-an-indicator" id="toc-collapse-control-variables-into-an-indicator" class="nav-link" data-scroll-target="#collapse-control-variables-into-an-indicator">Collapse control variables into an indicator</a></li>
  <li><a href="#subgroup-estimation-with-nest_by" id="toc-subgroup-estimation-with-nest_by" class="nav-link" data-scroll-target="#subgroup-estimation-with-nest_by">Subgroup estimation with <code>nest_by</code></a></li>
  <li><a href="#bootstrap" id="toc-bootstrap" class="nav-link" data-scroll-target="#bootstrap">Bootstrap</a></li>
  <li>
<a href="#fixest-fixed-effects" id="toc-fixest-fixed-effects" class="nav-link" data-scroll-target="#fixest-fixed-effects"><code>fixest</code>: Fixed effects</a>
  <ul class="collapse">
<li><a href="#instrumental-variable-regression" id="toc-instrumental-variable-regression" class="nav-link" data-scroll-target="#instrumental-variable-regression">Instrumental variable regression</a></li>
  <li><a href="#customizing-fixed-effects-indicators" id="toc-customizing-fixed-effects-indicators" class="nav-link" data-scroll-target="#customizing-fixed-effects-indicators">Customizing fixed effects indicators</a></li>
  </ul>
</li>
  <li><a href="#multiple-imputation" id="toc-multiple-imputation" class="nav-link" data-scroll-target="#multiple-imputation">Multiple imputation</a></li>
  </ul>
</li>
  <li>
<a href="#faq" id="toc-faq" class="nav-link" data-scroll-target="#faq">FAQ</a>
  <ul class="collapse">
<li><a href="#stack-overflow-is-useful" id="toc-stack-overflow-is-useful" class="nav-link" data-scroll-target="#stack-overflow-is-useful">Stack Overflow is useful</a></li>
  <li><a href="#where-can-i-get-help" id="toc-where-can-i-get-help" class="nav-link" data-scroll-target="#where-can-i-get-help">Where can I get help?</a></li>
  <li><a href="#how-can-i-add-or-modify-statistics-in-a-table" id="toc-how-can-i-add-or-modify-statistics-in-a-table" class="nav-link" data-scroll-target="#how-can-i-add-or-modify-statistics-in-a-table">How can I add or modify statistics in a table?</a></li>
  <li><a href="#how-does-modelsummary-extract-estimates-and-goodness-of-fit-statistics" id="toc-how-does-modelsummary-extract-estimates-and-goodness-of-fit-statistics" class="nav-link" data-scroll-target="#how-does-modelsummary-extract-estimates-and-goodness-of-fit-statistics">How does <code>modelsummary</code> extract estimates and goodness-of-fit statistics?</a></li>
  <li><a href="#how-can-i-speed-up-modelsummary" id="toc-how-can-i-speed-up-modelsummary" class="nav-link" data-scroll-target="#how-can-i-speed-up-modelsummary">How can I speed up <code>modelsummary</code>?</a></li>
  <li><a href="#escaped-latex-characters" id="toc-escaped-latex-characters" class="nav-link" data-scroll-target="#escaped-latex-characters">Escaped LaTeX characters</a></li>
  <li><a href="#bayesian-models" id="toc-bayesian-models" class="nav-link" data-scroll-target="#bayesian-models">Bayesian models</a></li>
  <li><a href="#factor-labels" id="toc-factor-labels" class="nav-link" data-scroll-target="#factor-labels">Factor labels</a></li>
  <li><a href="#footnotes-in-column-names" id="toc-footnotes-in-column-names" class="nav-link" data-scroll-target="#footnotes-in-column-names">Footnotes in column names</a></li>
  </ul>
</li>
  </ul></nav>
    </div>
<!-- main -->
<main class="content" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block default"><div class="quarto-title">
<h1 class="title">Model Summaries</h1>
</div>



<div class="quarto-title-meta">

    
  
    
  </div>
  


</header><div class="cell">
<style type="text/css">
.table, th, td {
  font-size: 0.9em;
} 
.table tbody td, .table thead tr {
    white-space: nowrap;
}
</style>
</div>
<p><code>modelsummary</code> includes a powerful set of utilities to customize the information displayed in your model summary tables. You can easily rename, reorder, subset or omit parameter estimates; choose the set of goodness-of-fit statistics to display; display various “robust” standard errors or confidence intervals; add titles, footnotes, or source notes; insert stars or custom characters to indicate levels of statistical significance; or add rows with supplemental information about your models.</p>
<p>Before starting, we set a few CSS properties to make tables more display in a more compact format on this website. This step is optional.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode default code-with-copy"><code class="sourceCode default"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>```{css, echo=FALSE}</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>.table, th, td {</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>  font-size: 0.9em;</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>} </span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>.table tbody td, .table thead tr {</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>    white-space: nowrap;</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a>```</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Now, we download data, fit some models, and summarize them in a table using the <code><a href="https://modelsummary.com/man/modelsummary.html">modelsummary()</a></code> function:</p>
<div class="cell">
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://modelsummary.com">modelsummary</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">url</span> <span class="op">&lt;-</span> <span class="st">'https://vincentarelbundock.github.io/Rdatasets/csv/HistData/Guerry.csv'</span></span>
<span><span class="va">dat</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/utils/read.table.html">read.csv</a></span><span class="op">(</span><span class="va">url</span><span class="op">)</span></span>
<span></span>
<span><span class="va">models</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="st">"OLS 1"</span>     <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">Donations</span> <span class="op">~</span> <span class="va">Literacy</span> <span class="op">+</span> <span class="va">Clergy</span>, data <span class="op">=</span> <span class="va">dat</span><span class="op">)</span>,</span>
<span>  <span class="st">"Poisson"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/glm.html">glm</a></span><span class="op">(</span><span class="va">Donations</span> <span class="op">~</span> <span class="va">Literacy</span> <span class="op">+</span> <span class="va">Commerce</span>, family <span class="op">=</span> <span class="va">poisson</span>, data <span class="op">=</span> <span class="va">dat</span><span class="op">)</span>,</span>
<span>  <span class="st">"OLS 2"</span>     <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">Crime_pers</span> <span class="op">~</span> <span class="va">Literacy</span> <span class="op">+</span> <span class="va">Clergy</span>, data <span class="op">=</span> <span class="va">dat</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_m1ruf5wt0tc9rsorl5n3(i, j, css_id) {
          var table = document.getElementById("tinytable_m1ruf5wt0tc9rsorl5n3");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_m1ruf5wt0tc9rsorl5n3(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_m1ruf5wt0tc9rsorl5n3");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 }, { i: '16', j: 2 }, { i: '16', j: 3 },  ], css_id: 'tinytable_css_dsd0tk3ocnv4l8kw7trs',}, 
          { positions: [ { i: '8', j: 2 }, { i: '8', j: 1 }, { i: '8', j: 3 },  ], css_id: 'tinytable_css_m7chzmgsivbikcxogpht',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '12', j: 2 }, { i: '4', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '4', j: 3 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '12', j: 3 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '15', j: 2 }, { i: '3', j: 3 }, { i: '13', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '7', j: 3 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '11', j: 3 }, { i: '9', j: 3 }, { i: '10', j: 3 }, { i: '15', j: 3 }, { i: '14', j: 3 },  ], css_id: 'tinytable_css_06olxi701reywtio8jan',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_xdaiek2nanqh8dlhz16r',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_gm1gsil5h39ge13yh1mp',}, 
          { positions: [ { i: '8', j: 0 },  ], css_id: 'tinytable_css_r4pmh68cw254egs8093k',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '12', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_1vpt9vzxu3fkd8ih5xra',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_mhni9nld1gg56vx51aqw',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_m1ruf5wt0tc9rsorl5n3(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_dsd0tk3ocnv4l8kw7trs, .table th.tinytable_css_dsd0tk3ocnv4l8kw7trs { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_m7chzmgsivbikcxogpht, .table th.tinytable_css_m7chzmgsivbikcxogpht { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_06olxi701reywtio8jan, .table th.tinytable_css_06olxi701reywtio8jan { text-align: center; }
      .table td.tinytable_css_xdaiek2nanqh8dlhz16r, .table th.tinytable_css_xdaiek2nanqh8dlhz16r { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_gm1gsil5h39ge13yh1mp, .table th.tinytable_css_gm1gsil5h39ge13yh1mp { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_r4pmh68cw254egs8093k, .table th.tinytable_css_r4pmh68cw254egs8093k { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_1vpt9vzxu3fkd8ih5xra, .table th.tinytable_css_1vpt9vzxu3fkd8ih5xra { text-align: left; }
      .table td.tinytable_css_mhni9nld1gg56vx51aqw, .table th.tinytable_css_mhni9nld1gg56vx51aqw { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_m1ruf5wt0tc9rsorl5n3" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667</td>
                  <td data-row="1" data-col="2">8.241</td>
                  <td data-row="1" data-col="3">16259.384</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(2078.276)</td>
                  <td data-row="2" data-col="2">(0.006)</td>
                  <td data-row="2" data-col="3">(2611.140)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-39.121</td>
                  <td data-row="3" data-col="2">0.003</td>
                  <td data-row="3" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(37.052)</td>
                  <td data-row="4" data-col="2">(0.000)</td>
                  <td data-row="4" data-col="3">(46.552)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Clergy</td>
                  <td data-row="5" data-col="1">15.257</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(25.735)</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">(32.334)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Commerce</td>
                  <td data-row="7" data-col="1"></td>
                  <td data-row="7" data-col="2">0.011</td>
                  <td data-row="7" data-col="3"></td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">(0.000)</td>
                  <td data-row="8" data-col="3"></td>
                </tr>
<tr>
<td data-row="9" data-col="0">Num.Obs.</td>
                  <td data-row="9" data-col="1">86</td>
                  <td data-row="9" data-col="2">86</td>
                  <td data-row="9" data-col="3">86</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2</td>
                  <td data-row="10" data-col="1">0.020</td>
                  <td data-row="10" data-col="2"></td>
                  <td data-row="10" data-col="3">0.065</td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Adj.</td>
                  <td data-row="11" data-col="1">-0.003</td>
                  <td data-row="11" data-col="2"></td>
                  <td data-row="11" data-col="3">0.043</td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">1740.8</td>
                  <td data-row="12" data-col="2">274160.8</td>
                  <td data-row="12" data-col="3">1780.0</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">1750.6</td>
                  <td data-row="13" data-col="2">274168.2</td>
                  <td data-row="13" data-col="3">1789.9</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Log.Lik.</td>
                  <td data-row="14" data-col="1">-866.392</td>
                  <td data-row="14" data-col="2">-137077.401</td>
                  <td data-row="14" data-col="3">-886.021</td>
                </tr>
<tr>
<td data-row="15" data-col="0">F</td>
                  <td data-row="15" data-col="1">0.866</td>
                  <td data-row="15" data-col="2">18294.559</td>
                  <td data-row="15" data-col="3">2.903</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">5740.99</td>
                  <td data-row="16" data-col="2">5491.61</td>
                  <td data-row="16" data-col="3">7212.97</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<section id="output" class="level1"><h1><code>output</code></h1>
<p>The <code>output</code> argument determines the type of object returned by <code>modelsummary</code> and/or the file where this table should be written.</p>
<p>If you want to save a table directly to file, you can type:</p>
<div class="cell">
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"table.docx"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"table.html"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"table.tex"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"table.md"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"table.txt"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"table.png"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>If you want a raw HTML, LaTeX, or Markdown table, you can type:</p>
<div class="cell">
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"html"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"latex"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"markdown"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>If you to customize the appearance of your table using external tools like <code>gt</code>, <code>kableExtra</code>, <code>flextable</code>, or <code>huxtable</code>, you can type:</p>
<div class="cell">
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"gt"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"kableExtra"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"flextable"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"huxtable"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Warning: When a file name is supplied to the <code>output</code> argument, the table is written immediately to file. If you want to customize your table by post-processing it with an external package, you need to choose a different output format and saving mechanism. The saving function differs from package to package:</p>
<ul>
<li>
<code>tinytable</code>: set <code>output="tinytable"</code>, post-process your table, and use the <code><a href="https://vincentarelbundock.github.io/tinytable/man/save_tt.html">tinytable::save_tt()</a></code> function.</li>
<li>
<code>gt</code>: set <code>output="gt"</code>, post-process your table, and use the <code><a href="https://gt.rstudio.com/reference/gtsave.html">gt::gtsave()</a></code> function.</li>
<li>
<code>kableExtra</code>: set <code>output</code> to your destination format (e.g., “latex”, “html”, “markdown”), post-process your table, and use <code><a href="https://rdrr.io/pkg/kableExtra/man/save_kable.html">kableExtra::save_kable()</a></code> function.</li>
</ul>
<p>For example:</p>
<div class="cell">
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://vincentarelbundock.github.io/tinytable/">tinytable</a></span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, output <span class="op">=</span> <span class="st">"tinytable"</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="https://vincentarelbundock.github.io/tinytable/man/style_tt.html">style_tt</a></span><span class="op">(</span>i <span class="op">=</span> <span class="fl">1</span>, background <span class="op">=</span> <span class="st">"pink"</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="https://vincentarelbundock.github.io/tinytable/man/save_tt.html">save_tt</a></span><span class="op">(</span><span class="st">"table.html"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section><section id="fmt" class="level1"><h1><code>fmt</code></h1>
<p>The <code>fmt</code> argument defines how numeric values are rounded and presented in the table. This argument accepts three types of input:</p>
<ul>
<li>Integer: Number of decimal digits</li>
<li>User-supplied function: Accepts a numeric vector and returns a character vector of the same length.</li>
<li>
<code>modelsummary</code> function: <code><a href="https://modelsummary.com/man/fmt_decimal.html">fmt_decimal()</a></code>, <code><a href="https://modelsummary.com/man/fmt_significant.html">fmt_significant()</a></code>, <code><a href="https://modelsummary.com/man/fmt_sprintf.html">fmt_sprintf()</a></code>, <code><a href="https://modelsummary.com/man/fmt_term.html">fmt_term()</a></code>, <code>fmt_statistic</code>, <code>fmt_identity()</code>
</li>
</ul>
<p>Examples:</p>
<div class="cell">
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">drat</span> <span class="op">+</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># decimal digits</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fl">3</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># user-supplied function</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="va">x</span>, <span class="fl">2</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># p values with different number of digits</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_decimal.html">fmt_decimal</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">3</span><span class="op">)</span>, statistic <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"std.error"</span>, <span class="st">"p.value"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># significant digits</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_significant.html">fmt_significant</a></span><span class="op">(</span><span class="fl">3</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># sprintf(): decimal digits</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_sprintf.html">fmt_sprintf</a></span><span class="op">(</span><span class="st">"%.5f"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># sprintf(): scientific notation </span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_sprintf.html">fmt_sprintf</a></span><span class="op">(</span><span class="st">"%.5e"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># statistic-specific formatting</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_statistic.html">fmt_statistic</a></span><span class="op">(</span>estimate <span class="op">=</span> <span class="fl">4</span>, conf.int <span class="op">=</span> <span class="fl">1</span><span class="op">)</span>, statistic <span class="op">=</span> <span class="st">"conf.int"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># term-specific formatting</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_term.html">fmt_term</a></span><span class="op">(</span>hp <span class="op">=</span> <span class="fl">4</span>, drat <span class="op">=</span> <span class="fl">1</span>, default <span class="op">=</span> <span class="fu"><a href="https://modelsummary.com/man/fmt_significant.html">fmt_significant</a></span><span class="op">(</span><span class="fl">2</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, fmt <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Custom formatting function with big mark commas:</p>
<div class="cell">
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">modf</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/AsIs.html">I</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">*</span> <span class="fl">100</span><span class="op">)</span> <span class="op">~</span> <span class="va">hp</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="va">f</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/formatc.html">formatC</a></span><span class="op">(</span><span class="va">x</span>, digits <span class="op">=</span> <span class="fl">2</span>, big.mark <span class="op">=</span> <span class="st">","</span>, format <span class="op">=</span> <span class="st">"f"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">modf</span>, fmt <span class="op">=</span> <span class="va">f</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_3ht9r1u3cgrk2qch6ze7(i, j, css_id) {
          var table = document.getElementById("tinytable_3ht9r1u3cgrk2qch6ze7");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_3ht9r1u3cgrk2qch6ze7(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_3ht9r1u3cgrk2qch6ze7");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 },  ], css_id: 'tinytable_css_8ivp8xvlp4tc61kjq0y8',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 },  ], css_id: 'tinytable_css_72j7mygc7e07iyexhbpt',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_hgz0c5ojkee6o1h1zrvw',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_cm740p1cx749p47yiqvf',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_48ek9q5t6hi3w2v4k3h5',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_ewu3n629yxl1hntyu2wx',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_3ht9r1u3cgrk2qch6ze7(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_8ivp8xvlp4tc61kjq0y8, .table th.tinytable_css_8ivp8xvlp4tc61kjq0y8 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_72j7mygc7e07iyexhbpt, .table th.tinytable_css_72j7mygc7e07iyexhbpt { text-align: center; }
      .table td.tinytable_css_hgz0c5ojkee6o1h1zrvw, .table th.tinytable_css_hgz0c5ojkee6o1h1zrvw { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_cm740p1cx749p47yiqvf, .table th.tinytable_css_cm740p1cx749p47yiqvf { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_48ek9q5t6hi3w2v4k3h5, .table th.tinytable_css_48ek9q5t6hi3w2v4k3h5 { text-align: left; }
      .table td.tinytable_css_ewu3n629yxl1hntyu2wx, .table th.tinytable_css_ewu3n629yxl1hntyu2wx { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_3ht9r1u3cgrk2qch6ze7" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">3,009.89</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(163.39)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">-6.82</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(1.01)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>In many languages the comma is used as a decimal mark instead of the period. <code>modelsummary</code> respects the global <code>R</code> <code>OutDec</code> option, so you can simply execute this command and your tables will be adjusted automatically:</p>
<div class="cell">
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>OutDec<span class="op">=</span><span class="st">","</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section><section id="estimate" class="level1"><h1><code>estimate</code></h1>
<p>By default, <code>modelsummary</code> prints each coefficient estimate on its own row. You can customize this by changing the <code>estimate</code> argument. For example, this would produce a table of p values instead of coefficient estimates:</p>
<div class="cell">
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, estimate <span class="op">=</span> <span class="st">"p.value"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>You can also use <a href="https://glue.tidyverse.org/">glue string</a>, using curly braces to specify the statistics you want. For example, this displays the estimate next to a confidence interval:</p>
<div class="cell">
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">models</span>,</span>
<span>  fmt <span class="op">=</span> <span class="fl">1</span>,</span>
<span>  estimate  <span class="op">=</span> <span class="st">"{estimate} [{conf.low}, {conf.high}]"</span>,</span>
<span>  statistic <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  coef_omit <span class="op">=</span> <span class="st">"Intercept"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_8v5m033mzzn3mllzu29f(i, j, css_id) {
          var table = document.getElementById("tinytable_8v5m033mzzn3mllzu29f");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_8v5m033mzzn3mllzu29f(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_8v5m033mzzn3mllzu29f");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '11', j: 2 }, { i: '11', j: 1 }, { i: '11', j: 3 },  ], css_id: 'tinytable_css_xvsi4js7ir60ple3y59l',}, 
          { positions: [ { i: '3', j: 3 }, { i: '3', j: 2 }, { i: '3', j: 1 },  ], css_id: 'tinytable_css_8gltztjtuvqtfj3ab0zb',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '4', j: 3 }, { i: '5', j: 3 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '7', j: 3 }, { i: '8', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '9', j: 3 }, { i: '6', j: 3 }, { i: '10', j: 3 },  ], css_id: 'tinytable_css_5e844i30ruyao4nk9ak2',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_dfmhb8yliiznl6g0kfhi',}, 
          { positions: [ { i: '11', j: 0 },  ], css_id: 'tinytable_css_no7sohmubmc20lc7ck6t',}, 
          { positions: [ { i: '3', j: 0 },  ], css_id: 'tinytable_css_irhgz2itenfkxtzvdblh',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '7', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 },  ], css_id: 'tinytable_css_qqzelqolbv033jmdywoh',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_rkyjiug82zu45lqed73m',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_8v5m033mzzn3mllzu29f(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_xvsi4js7ir60ple3y59l, .table th.tinytable_css_xvsi4js7ir60ple3y59l { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_8gltztjtuvqtfj3ab0zb, .table th.tinytable_css_8gltztjtuvqtfj3ab0zb { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_5e844i30ruyao4nk9ak2, .table th.tinytable_css_5e844i30ruyao4nk9ak2 { text-align: center; }
      .table td.tinytable_css_dfmhb8yliiznl6g0kfhi, .table th.tinytable_css_dfmhb8yliiznl6g0kfhi { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_no7sohmubmc20lc7ck6t, .table th.tinytable_css_no7sohmubmc20lc7ck6t { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_irhgz2itenfkxtzvdblh, .table th.tinytable_css_irhgz2itenfkxtzvdblh { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_qqzelqolbv033jmdywoh, .table th.tinytable_css_qqzelqolbv033jmdywoh { text-align: left; }
      .table td.tinytable_css_rkyjiug82zu45lqed73m, .table th.tinytable_css_rkyjiug82zu45lqed73m { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_8v5m033mzzn3mllzu29f" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Literacy</td>
                  <td data-row="1" data-col="1">-39.1 [-112.8, 34.6]</td>
                  <td data-row="1" data-col="2">0.0 [0.0, 0.0]</td>
                  <td data-row="1" data-col="3">3.7 [-88.9, 96.3]</td>
                </tr>
<tr>
<td data-row="2" data-col="0">Clergy</td>
                  <td data-row="2" data-col="1">15.3 [-35.9, 66.4]</td>
                  <td data-row="2" data-col="2"></td>
                  <td data-row="2" data-col="3">77.1 [12.8, 141.5]</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Commerce</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2">0.0 [0.0, 0.0]</td>
                  <td data-row="3" data-col="3"></td>
                </tr>
<tr>
<td data-row="4" data-col="0">Num.Obs.</td>
                  <td data-row="4" data-col="1">86</td>
                  <td data-row="4" data-col="2">86</td>
                  <td data-row="4" data-col="3">86</td>
                </tr>
<tr>
<td data-row="5" data-col="0">R2</td>
                  <td data-row="5" data-col="1">0.020</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">0.065</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2 Adj.</td>
                  <td data-row="6" data-col="1">-0.003</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">0.043</td>
                </tr>
<tr>
<td data-row="7" data-col="0">AIC</td>
                  <td data-row="7" data-col="1">1740.8</td>
                  <td data-row="7" data-col="2">274160.8</td>
                  <td data-row="7" data-col="3">1780.0</td>
                </tr>
<tr>
<td data-row="8" data-col="0">BIC</td>
                  <td data-row="8" data-col="1">1750.6</td>
                  <td data-row="8" data-col="2">274168.2</td>
                  <td data-row="8" data-col="3">1789.9</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Log.Lik.</td>
                  <td data-row="9" data-col="1">-866.392</td>
                  <td data-row="9" data-col="2">-137077.401</td>
                  <td data-row="9" data-col="3">-886.021</td>
                </tr>
<tr>
<td data-row="10" data-col="0">F</td>
                  <td data-row="10" data-col="1">0.866</td>
                  <td data-row="10" data-col="2">18294.559</td>
                  <td data-row="10" data-col="3">2.903</td>
                </tr>
<tr>
<td data-row="11" data-col="0">RMSE</td>
                  <td data-row="11" data-col="1">5740.99</td>
                  <td data-row="11" data-col="2">5491.61</td>
                  <td data-row="11" data-col="3">7212.97</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Glue strings can also apply R functions to estimates. However, since <code>modelsummary</code> rounds numbers and transforms them to character by default, we must set <code>fmt = NULL</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">m</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/glm.html">glm</a></span><span class="op">(</span><span class="va">am</span> <span class="op">~</span> <span class="va">mpg</span>, data <span class="op">=</span> <span class="va">mtcars</span>, family <span class="op">=</span> <span class="va">binomial</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>    <span class="va">m</span>,</span>
<span>    fmt <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>    estimate <span class="op">=</span> <span class="st">"{round(exp(estimate), 5)}"</span>,</span>
<span>    statistic <span class="op">=</span> <span class="st">"{round(exp(estimate) * std.error, 3)}"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_dh7ln1lessg2lue6083g(i, j, css_id) {
          var table = document.getElementById("tinytable_dh7ln1lessg2lue6083g");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_dh7ln1lessg2lue6083g(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_dh7ln1lessg2lue6083g");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 1 },  ], css_id: 'tinytable_css_c9k7hg1sru36fi40zm6m',}, 
          { positions: [ { i: '4', j: 1 },  ], css_id: 'tinytable_css_pqoegpx0b3j1hyzmjxne',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '8', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 },  ], css_id: 'tinytable_css_5zmdn5abqkgtjod5v0gv',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_0gnqrfy05q4yuor3p8d6',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_fqmsbqxxi7bpupmolb36',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_xbkzc31g8gxtmzngt3cj',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 },  ], css_id: 'tinytable_css_k09j8x5xz34yrxg4465n',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_4livutv2h1u9ep0fn2v9',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_dh7ln1lessg2lue6083g(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_c9k7hg1sru36fi40zm6m, .table th.tinytable_css_c9k7hg1sru36fi40zm6m { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_pqoegpx0b3j1hyzmjxne, .table th.tinytable_css_pqoegpx0b3j1hyzmjxne { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_5zmdn5abqkgtjod5v0gv, .table th.tinytable_css_5zmdn5abqkgtjod5v0gv { text-align: center; }
      .table td.tinytable_css_0gnqrfy05q4yuor3p8d6, .table th.tinytable_css_0gnqrfy05q4yuor3p8d6 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_fqmsbqxxi7bpupmolb36, .table th.tinytable_css_fqmsbqxxi7bpupmolb36 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_xbkzc31g8gxtmzngt3cj, .table th.tinytable_css_xbkzc31g8gxtmzngt3cj { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_k09j8x5xz34yrxg4465n, .table th.tinytable_css_k09j8x5xz34yrxg4465n { text-align: left; }
      .table td.tinytable_css_4livutv2h1u9ep0fn2v9, .table th.tinytable_css_4livutv2h1u9ep0fn2v9 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_dh7ln1lessg2lue6083g" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">0.00136</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">0.003</td>
                </tr>
<tr>
<td data-row="3" data-col="0">mpg</td>
                  <td data-row="3" data-col="1">1.35938</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">0.156</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">AIC</td>
                  <td data-row="6" data-col="1">33.7</td>
                </tr>
<tr>
<td data-row="7" data-col="0">BIC</td>
                  <td data-row="7" data-col="1">36.6</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Log.Lik.</td>
                  <td data-row="8" data-col="1">-14.838</td>
                </tr>
<tr>
<td data-row="9" data-col="0">F</td>
                  <td data-row="9" data-col="1">7.148</td>
                </tr>
<tr>
<td data-row="10" data-col="0">RMSE</td>
                  <td data-row="10" data-col="1">0.39</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>You can also use different estimates for different models by using a vector of strings:</p>
<div class="cell">
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">models</span>,</span>
<span>  fmt <span class="op">=</span> <span class="fl">1</span>,</span>
<span>  estimate  <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"estimate"</span>,</span>
<span>                <span class="st">"{estimate}{stars}"</span>,</span>
<span>                <span class="st">"{estimate} ({std.error})"</span><span class="op">)</span>,</span>
<span>  statistic <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  coef_omit <span class="op">=</span> <span class="st">"Intercept"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_4444ugxcdh52bdl5olql(i, j, css_id) {
          var table = document.getElementById("tinytable_4444ugxcdh52bdl5olql");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_4444ugxcdh52bdl5olql(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_4444ugxcdh52bdl5olql");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '11', j: 2 }, { i: '11', j: 1 }, { i: '11', j: 3 },  ], css_id: 'tinytable_css_wfxakdjcl4352e26fcf6',}, 
          { positions: [ { i: '3', j: 3 }, { i: '3', j: 2 }, { i: '3', j: 1 },  ], css_id: 'tinytable_css_jhl26xi5mlucq9l5wol9',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '4', j: 3 }, { i: '5', j: 3 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '7', j: 3 }, { i: '8', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '9', j: 3 }, { i: '6', j: 3 }, { i: '10', j: 3 },  ], css_id: 'tinytable_css_zpkr492ztfqlxz9380z8',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_x64augijn1twubf0pxgn',}, 
          { positions: [ { i: '11', j: 0 },  ], css_id: 'tinytable_css_avvyev1oqlfquij6gzhd',}, 
          { positions: [ { i: '3', j: 0 },  ], css_id: 'tinytable_css_pq1ktjs7zio3a9x2o7np',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '7', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 },  ], css_id: 'tinytable_css_uzwmekdpga5ekdmtc58p',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_eszobzm2g6gqvg0d6ouk',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_4444ugxcdh52bdl5olql(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_wfxakdjcl4352e26fcf6, .table th.tinytable_css_wfxakdjcl4352e26fcf6 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_jhl26xi5mlucq9l5wol9, .table th.tinytable_css_jhl26xi5mlucq9l5wol9 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_zpkr492ztfqlxz9380z8, .table th.tinytable_css_zpkr492ztfqlxz9380z8 { text-align: center; }
      .table td.tinytable_css_x64augijn1twubf0pxgn, .table th.tinytable_css_x64augijn1twubf0pxgn { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_avvyev1oqlfquij6gzhd, .table th.tinytable_css_avvyev1oqlfquij6gzhd { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_pq1ktjs7zio3a9x2o7np, .table th.tinytable_css_pq1ktjs7zio3a9x2o7np { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_uzwmekdpga5ekdmtc58p, .table th.tinytable_css_uzwmekdpga5ekdmtc58p { text-align: left; }
      .table td.tinytable_css_eszobzm2g6gqvg0d6ouk, .table th.tinytable_css_eszobzm2g6gqvg0d6ouk { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_4444ugxcdh52bdl5olql" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Literacy</td>
                  <td data-row="1" data-col="1">-39.1</td>
                  <td data-row="1" data-col="2">0.0***</td>
                  <td data-row="1" data-col="3">3.7 (46.6)</td>
                </tr>
<tr>
<td data-row="2" data-col="0">Clergy</td>
                  <td data-row="2" data-col="1">15.3</td>
                  <td data-row="2" data-col="2"></td>
                  <td data-row="2" data-col="3">77.1 (32.3)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Commerce</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2">0.0***</td>
                  <td data-row="3" data-col="3"></td>
                </tr>
<tr>
<td data-row="4" data-col="0">Num.Obs.</td>
                  <td data-row="4" data-col="1">86</td>
                  <td data-row="4" data-col="2">86</td>
                  <td data-row="4" data-col="3">86</td>
                </tr>
<tr>
<td data-row="5" data-col="0">R2</td>
                  <td data-row="5" data-col="1">0.020</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">0.065</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2 Adj.</td>
                  <td data-row="6" data-col="1">-0.003</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">0.043</td>
                </tr>
<tr>
<td data-row="7" data-col="0">AIC</td>
                  <td data-row="7" data-col="1">1740.8</td>
                  <td data-row="7" data-col="2">274160.8</td>
                  <td data-row="7" data-col="3">1780.0</td>
                </tr>
<tr>
<td data-row="8" data-col="0">BIC</td>
                  <td data-row="8" data-col="1">1750.6</td>
                  <td data-row="8" data-col="2">274168.2</td>
                  <td data-row="8" data-col="3">1789.9</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Log.Lik.</td>
                  <td data-row="9" data-col="1">-866.392</td>
                  <td data-row="9" data-col="2">-137077.401</td>
                  <td data-row="9" data-col="3">-886.021</td>
                </tr>
<tr>
<td data-row="10" data-col="0">F</td>
                  <td data-row="10" data-col="1">0.866</td>
                  <td data-row="10" data-col="2">18294.559</td>
                  <td data-row="10" data-col="3">2.903</td>
                </tr>
<tr>
<td data-row="11" data-col="0">RMSE</td>
                  <td data-row="11" data-col="1">5740.99</td>
                  <td data-row="11" data-col="2">5491.61</td>
                  <td data-row="11" data-col="3">7212.97</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="statistic" class="level1"><h1><code>statistic</code></h1>
<p>By default, <code>modelsummary</code> prints the coefficient’s standard error in parentheses below the corresponding estimate. The value of this uncertainty statistic is determined by the <code>statistic</code> argument. The <code>statistic</code> argument accepts any of the column names produced by <code>get_estimates(model)</code>. For example:</p>
<div class="cell">
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, statistic <span class="op">=</span> <span class="st">'std.error'</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, statistic <span class="op">=</span> <span class="st">'p.value'</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, statistic <span class="op">=</span> <span class="st">'statistic'</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>You can also display confidence intervals in brackets by setting <code>statistic="conf.int"</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>,</span>
<span>             fmt <span class="op">=</span> <span class="fl">1</span>,</span>
<span>             statistic <span class="op">=</span> <span class="st">'conf.int'</span>, </span>
<span>             conf_level <span class="op">=</span> <span class="fl">.99</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_2cioj0pny119wlodtfmo(i, j, css_id) {
          var table = document.getElementById("tinytable_2cioj0pny119wlodtfmo");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_2cioj0pny119wlodtfmo(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_2cioj0pny119wlodtfmo");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 }, { i: '16', j: 2 }, { i: '16', j: 3 },  ], css_id: 'tinytable_css_ezk79pcz4nhgs764dwrr',}, 
          { positions: [ { i: '8', j: 2 }, { i: '8', j: 1 }, { i: '8', j: 3 },  ], css_id: 'tinytable_css_qjzazz1odmhxh3fjg4dg',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '12', j: 2 }, { i: '4', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '4', j: 3 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '12', j: 3 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '15', j: 2 }, { i: '3', j: 3 }, { i: '13', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '7', j: 3 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '11', j: 3 }, { i: '9', j: 3 }, { i: '10', j: 3 }, { i: '15', j: 3 }, { i: '14', j: 3 },  ], css_id: 'tinytable_css_7w09oss31gwqpqa03m0k',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_wwz85i6obj70zq5vsrax',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_rddh6dcaz8o6da5bsirc',}, 
          { positions: [ { i: '8', j: 0 },  ], css_id: 'tinytable_css_t8tiwnakln5d77szzcjh',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '12', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_1u2jcy58z5f24z1d10oe',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_zyfy0oao8o5civrn6vjw',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_2cioj0pny119wlodtfmo(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_ezk79pcz4nhgs764dwrr, .table th.tinytable_css_ezk79pcz4nhgs764dwrr { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_qjzazz1odmhxh3fjg4dg, .table th.tinytable_css_qjzazz1odmhxh3fjg4dg { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_7w09oss31gwqpqa03m0k, .table th.tinytable_css_7w09oss31gwqpqa03m0k { text-align: center; }
      .table td.tinytable_css_wwz85i6obj70zq5vsrax, .table th.tinytable_css_wwz85i6obj70zq5vsrax { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_rddh6dcaz8o6da5bsirc, .table th.tinytable_css_rddh6dcaz8o6da5bsirc { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_t8tiwnakln5d77szzcjh, .table th.tinytable_css_t8tiwnakln5d77szzcjh { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_1u2jcy58z5f24z1d10oe, .table th.tinytable_css_1u2jcy58z5f24z1d10oe { text-align: left; }
      .table td.tinytable_css_zyfy0oao8o5civrn6vjw, .table th.tinytable_css_zyfy0oao8o5civrn6vjw { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_2cioj0pny119wlodtfmo" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.7</td>
                  <td data-row="1" data-col="2">8.2</td>
                  <td data-row="1" data-col="3">16259.4</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">[2469.6, 13427.8]</td>
                  <td data-row="2" data-col="2">[8.2, 8.3]</td>
                  <td data-row="2" data-col="3">[9375.5, 23143.3]</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-39.1</td>
                  <td data-row="3" data-col="2">0.0</td>
                  <td data-row="3" data-col="3">3.7</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">[-136.8, 58.6]</td>
                  <td data-row="4" data-col="2">[0.0, 0.0]</td>
                  <td data-row="4" data-col="3">[-119.0, 126.4]</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Clergy</td>
                  <td data-row="5" data-col="1">15.3</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">77.1</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">[-52.6, 83.1]</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">[-8.1, 162.4]</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Commerce</td>
                  <td data-row="7" data-col="1"></td>
                  <td data-row="7" data-col="2">0.0</td>
                  <td data-row="7" data-col="3"></td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">[0.0, 0.0]</td>
                  <td data-row="8" data-col="3"></td>
                </tr>
<tr>
<td data-row="9" data-col="0">Num.Obs.</td>
                  <td data-row="9" data-col="1">86</td>
                  <td data-row="9" data-col="2">86</td>
                  <td data-row="9" data-col="3">86</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2</td>
                  <td data-row="10" data-col="1">0.020</td>
                  <td data-row="10" data-col="2"></td>
                  <td data-row="10" data-col="3">0.065</td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Adj.</td>
                  <td data-row="11" data-col="1">-0.003</td>
                  <td data-row="11" data-col="2"></td>
                  <td data-row="11" data-col="3">0.043</td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">1740.8</td>
                  <td data-row="12" data-col="2">274160.8</td>
                  <td data-row="12" data-col="3">1780.0</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">1750.6</td>
                  <td data-row="13" data-col="2">274168.2</td>
                  <td data-row="13" data-col="3">1789.9</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Log.Lik.</td>
                  <td data-row="14" data-col="1">-866.392</td>
                  <td data-row="14" data-col="2">-137077.401</td>
                  <td data-row="14" data-col="3">-886.021</td>
                </tr>
<tr>
<td data-row="15" data-col="0">F</td>
                  <td data-row="15" data-col="1">0.866</td>
                  <td data-row="15" data-col="2">18294.559</td>
                  <td data-row="15" data-col="3">2.903</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">5740.99</td>
                  <td data-row="16" data-col="2">5491.61</td>
                  <td data-row="16" data-col="3">7212.97</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Alternatively, you can supply a <a href="https://glue.tidyverse.org/">glue string</a> to get more complicated results:</p>
<div class="cell">
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>,</span>
<span>             statistic <span class="op">=</span> <span class="st">"{std.error} ({p.value})"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_ag914m88z2zzt81kzbj0(i, j, css_id) {
          var table = document.getElementById("tinytable_ag914m88z2zzt81kzbj0");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_ag914m88z2zzt81kzbj0(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_ag914m88z2zzt81kzbj0");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 }, { i: '16', j: 2 }, { i: '16', j: 3 },  ], css_id: 'tinytable_css_ggkopo4g2cv0zw1arfuq',}, 
          { positions: [ { i: '8', j: 2 }, { i: '8', j: 1 }, { i: '8', j: 3 },  ], css_id: 'tinytable_css_hmobkrjyn0246j66j680',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '12', j: 2 }, { i: '4', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '4', j: 3 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '12', j: 3 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '15', j: 2 }, { i: '3', j: 3 }, { i: '13', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '7', j: 3 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '11', j: 3 }, { i: '9', j: 3 }, { i: '10', j: 3 }, { i: '15', j: 3 }, { i: '14', j: 3 },  ], css_id: 'tinytable_css_egah62m7ochicxh2pjh1',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_edikrxbd7mi7lvr6e3js',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_7ixy22tevf0mw6mbjgy7',}, 
          { positions: [ { i: '8', j: 0 },  ], css_id: 'tinytable_css_ue54uyq3hgm3vjjkrg29',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '12', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_hyidazi2zq32dpez3kd1',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_g6lhuion00r3ca45671a',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_ag914m88z2zzt81kzbj0(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_ggkopo4g2cv0zw1arfuq, .table th.tinytable_css_ggkopo4g2cv0zw1arfuq { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_hmobkrjyn0246j66j680, .table th.tinytable_css_hmobkrjyn0246j66j680 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_egah62m7ochicxh2pjh1, .table th.tinytable_css_egah62m7ochicxh2pjh1 { text-align: center; }
      .table td.tinytable_css_edikrxbd7mi7lvr6e3js, .table th.tinytable_css_edikrxbd7mi7lvr6e3js { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_7ixy22tevf0mw6mbjgy7, .table th.tinytable_css_7ixy22tevf0mw6mbjgy7 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ue54uyq3hgm3vjjkrg29, .table th.tinytable_css_ue54uyq3hgm3vjjkrg29 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_hyidazi2zq32dpez3kd1, .table th.tinytable_css_hyidazi2zq32dpez3kd1 { text-align: left; }
      .table td.tinytable_css_g6lhuion00r3ca45671a, .table th.tinytable_css_g6lhuion00r3ca45671a { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_ag914m88z2zzt81kzbj0" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667</td>
                  <td data-row="1" data-col="2">8.241</td>
                  <td data-row="1" data-col="3">16259.384</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">2078.276 (
                  </td>
<td data-row="2" data-col="2">0.006 (
                  </td>
<td data-row="2" data-col="3">2611.140 (
                </td>
</tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-39.121</td>
                  <td data-row="3" data-col="2">0.003</td>
                  <td data-row="3" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">37.052 (0.294)</td>
                  <td data-row="4" data-col="2">0.000 (
                  </td>
<td data-row="4" data-col="3">46.552 (0.937)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Clergy</td>
                  <td data-row="5" data-col="1">15.257</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">25.735 (0.555)</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">32.334 (0.019)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Commerce</td>
                  <td data-row="7" data-col="1"></td>
                  <td data-row="7" data-col="2">0.011</td>
                  <td data-row="7" data-col="3"></td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">0.000 (
                  </td>
<td data-row="8" data-col="3"></td>
                </tr>
<tr>
<td data-row="9" data-col="0">Num.Obs.</td>
                  <td data-row="9" data-col="1">86</td>
                  <td data-row="9" data-col="2">86</td>
                  <td data-row="9" data-col="3">86</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2</td>
                  <td data-row="10" data-col="1">0.020</td>
                  <td data-row="10" data-col="2"></td>
                  <td data-row="10" data-col="3">0.065</td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Adj.</td>
                  <td data-row="11" data-col="1">-0.003</td>
                  <td data-row="11" data-col="2"></td>
                  <td data-row="11" data-col="3">0.043</td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">1740.8</td>
                  <td data-row="12" data-col="2">274160.8</td>
                  <td data-row="12" data-col="3">1780.0</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">1750.6</td>
                  <td data-row="13" data-col="2">274168.2</td>
                  <td data-row="13" data-col="3">1789.9</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Log.Lik.</td>
                  <td data-row="14" data-col="1">-866.392</td>
                  <td data-row="14" data-col="2">-137077.401</td>
                  <td data-row="14" data-col="3">-886.021</td>
                </tr>
<tr>
<td data-row="15" data-col="0">F</td>
                  <td data-row="15" data-col="1">0.866</td>
                  <td data-row="15" data-col="2">18294.559</td>
                  <td data-row="15" data-col="3">2.903</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">5740.99</td>
                  <td data-row="16" data-col="2">5491.61</td>
                  <td data-row="16" data-col="3">7212.97</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>You can also display several different uncertainty estimates below the coefficient estimates by using a vector. For example,</p>
<div class="cell">
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, gof_omit <span class="op">=</span> <span class="st">".*"</span>,</span>
<span>             statistic <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"conf.int"</span>,</span>
<span>                           <span class="st">"s.e. = {std.error}"</span>, </span>
<span>                           <span class="st">"t = {statistic}"</span>,</span>
<span>                           <span class="st">"p = {p.value}"</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_uqfys0u6zelqldbqeofp(i, j, css_id) {
          var table = document.getElementById("tinytable_uqfys0u6zelqldbqeofp");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_uqfys0u6zelqldbqeofp(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_uqfys0u6zelqldbqeofp");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '20', j: 2 }, { i: '20', j: 1 }, { i: '20', j: 3 },  ], css_id: 'tinytable_css_guojpd78ujvwiiaod7ta',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '4', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '3', j: 1 }, { i: '17', j: 1 }, { i: '18', j: 1 }, { i: '19', j: 1 }, { i: '12', j: 2 }, { i: '8', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '16', j: 1 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '4', j: 3 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '15', j: 2 }, { i: '16', j: 2 }, { i: '17', j: 2 }, { i: '18', j: 2 }, { i: '19', j: 2 }, { i: '12', j: 3 }, { i: '8', j: 2 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '17', j: 3 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '7', j: 3 }, { i: '8', j: 3 }, { i: '9', j: 3 }, { i: '10', j: 3 }, { i: '11', j: 3 }, { i: '16', j: 3 }, { i: '13', j: 3 }, { i: '14', j: 3 }, { i: '15', j: 3 }, { i: '18', j: 3 }, { i: '19', j: 3 },  ], css_id: 'tinytable_css_wgb1hn17mhfsyp3xp7qj',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_4fnjnxthe3xlf4n9p0y6',}, 
          { positions: [ { i: '20', j: 0 },  ], css_id: 'tinytable_css_djmmzludldzbpbggynzn',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 }, { i: '16', j: 0 }, { i: '17', j: 0 }, { i: '18', j: 0 }, { i: '19', j: 0 },  ], css_id: 'tinytable_css_vkn50pqaq0e1yhpjm901',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_03k0hd3is6mz7ds4a81v',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_uqfys0u6zelqldbqeofp(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_guojpd78ujvwiiaod7ta, .table th.tinytable_css_guojpd78ujvwiiaod7ta { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_wgb1hn17mhfsyp3xp7qj, .table th.tinytable_css_wgb1hn17mhfsyp3xp7qj { text-align: center; }
      .table td.tinytable_css_4fnjnxthe3xlf4n9p0y6, .table th.tinytable_css_4fnjnxthe3xlf4n9p0y6 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_djmmzludldzbpbggynzn, .table th.tinytable_css_djmmzludldzbpbggynzn { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_vkn50pqaq0e1yhpjm901, .table th.tinytable_css_vkn50pqaq0e1yhpjm901 { text-align: left; }
      .table td.tinytable_css_03k0hd3is6mz7ds4a81v, .table th.tinytable_css_03k0hd3is6mz7ds4a81v { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_uqfys0u6zelqldbqeofp" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667</td>
                  <td data-row="1" data-col="2">8.241</td>
                  <td data-row="1" data-col="3">16259.384</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">[3815.060, 12082.275]</td>
                  <td data-row="2" data-col="2">[8.230, 8.252]</td>
                  <td data-row="2" data-col="3">[11065.933, 21452.836]</td>
                </tr>
<tr>
<td data-row="3" data-col="0"></td>
                  <td data-row="3" data-col="1">s.e. = 2078.276</td>
                  <td data-row="3" data-col="2">s.e. = 0.006</td>
                  <td data-row="3" data-col="3">s.e. = 2611.140</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">t = 3.825</td>
                  <td data-row="4" data-col="2">t = 1408.907</td>
                  <td data-row="4" data-col="3">t = 6.227</td>
                </tr>
<tr>
<td data-row="5" data-col="0"></td>
                  <td data-row="5" data-col="1">p = 
                  </td>
<td data-row="5" data-col="2">p = 
                  </td>
<td data-row="5" data-col="3">p = 
                </td>
</tr>
<tr>
<td data-row="6" data-col="0">Literacy</td>
                  <td data-row="6" data-col="1">-39.121</td>
                  <td data-row="6" data-col="2">0.003</td>
                  <td data-row="6" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="7" data-col="0"></td>
                  <td data-row="7" data-col="1">[-112.816, 34.574]</td>
                  <td data-row="7" data-col="2">[0.003, 0.003]</td>
                  <td data-row="7" data-col="3">[-88.910, 96.270]</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1">s.e. = 37.052</td>
                  <td data-row="8" data-col="2">s.e. = 0.000</td>
                  <td data-row="8" data-col="3">s.e. = 46.552</td>
                </tr>
<tr>
<td data-row="9" data-col="0"></td>
                  <td data-row="9" data-col="1">t = -1.056</td>
                  <td data-row="9" data-col="2">t = 33.996</td>
                  <td data-row="9" data-col="3">t = 0.079</td>
                </tr>
<tr>
<td data-row="10" data-col="0"></td>
                  <td data-row="10" data-col="1">p = 0.294</td>
                  <td data-row="10" data-col="2">p = 
                  </td>
<td data-row="10" data-col="3">p = 0.937</td>
                </tr>
<tr>
<td data-row="11" data-col="0">Clergy</td>
                  <td data-row="11" data-col="1">15.257</td>
                  <td data-row="11" data-col="2"></td>
                  <td data-row="11" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="12" data-col="0"></td>
                  <td data-row="12" data-col="1">[-35.930, 66.443]</td>
                  <td data-row="12" data-col="2"></td>
                  <td data-row="12" data-col="3">[12.837, 141.459]</td>
                </tr>
<tr>
<td data-row="13" data-col="0"></td>
                  <td data-row="13" data-col="1">s.e. = 25.735</td>
                  <td data-row="13" data-col="2"></td>
                  <td data-row="13" data-col="3">s.e. = 32.334</td>
                </tr>
<tr>
<td data-row="14" data-col="0"></td>
                  <td data-row="14" data-col="1">t = 0.593</td>
                  <td data-row="14" data-col="2"></td>
                  <td data-row="14" data-col="3">t = 2.386</td>
                </tr>
<tr>
<td data-row="15" data-col="0"></td>
                  <td data-row="15" data-col="1">p = 0.555</td>
                  <td data-row="15" data-col="2"></td>
                  <td data-row="15" data-col="3">p = 0.019</td>
                </tr>
<tr>
<td data-row="16" data-col="0">Commerce</td>
                  <td data-row="16" data-col="1"></td>
                  <td data-row="16" data-col="2">0.011</td>
                  <td data-row="16" data-col="3"></td>
                </tr>
<tr>
<td data-row="17" data-col="0"></td>
                  <td data-row="17" data-col="1"></td>
                  <td data-row="17" data-col="2">[0.011, 0.011]</td>
                  <td data-row="17" data-col="3"></td>
                </tr>
<tr>
<td data-row="18" data-col="0"></td>
                  <td data-row="18" data-col="1"></td>
                  <td data-row="18" data-col="2">s.e. = 0.000</td>
                  <td data-row="18" data-col="3"></td>
                </tr>
<tr>
<td data-row="19" data-col="0"></td>
                  <td data-row="19" data-col="1"></td>
                  <td data-row="19" data-col="2">t = 174.542</td>
                  <td data-row="19" data-col="3"></td>
                </tr>
<tr>
<td data-row="20" data-col="0"></td>
                  <td data-row="20" data-col="1"></td>
                  <td data-row="20" data-col="2">p = 
                  </td>
<td data-row="20" data-col="3"></td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Setting <code>statistic=NULL</code> omits all statistics. This can often be useful if, for example, you want to display confidence intervals next to coefficients:</p>
<div class="cell">
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, gof_omit <span class="op">=</span> <span class="st">".*"</span>,</span>
<span>             estimate <span class="op">=</span> <span class="st">"{estimate} [{conf.low}, {conf.high}]"</span>,</span>
<span>             statistic <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_znqx8uijkjsgy32d5jkd(i, j, css_id) {
          var table = document.getElementById("tinytable_znqx8uijkjsgy32d5jkd");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_znqx8uijkjsgy32d5jkd(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_znqx8uijkjsgy32d5jkd");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 3 },  ], css_id: 'tinytable_css_1qddrpvivg0r332eo8o4',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '1', j: 2 }, { i: '1', j: 3 },  ], css_id: 'tinytable_css_mwgztgy4jry90ts2envw',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_eofut5btlfh8qetien1h',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_skr86ntsprp74w19qre9',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_rckbefkhvh7dzt39ycjn',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_20asswrmt38h8iq37a68',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_znqx8uijkjsgy32d5jkd(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_1qddrpvivg0r332eo8o4, .table th.tinytable_css_1qddrpvivg0r332eo8o4 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_mwgztgy4jry90ts2envw, .table th.tinytable_css_mwgztgy4jry90ts2envw { text-align: center; }
      .table td.tinytable_css_eofut5btlfh8qetien1h, .table th.tinytable_css_eofut5btlfh8qetien1h { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_skr86ntsprp74w19qre9, .table th.tinytable_css_skr86ntsprp74w19qre9 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_rckbefkhvh7dzt39ycjn, .table th.tinytable_css_rckbefkhvh7dzt39ycjn { text-align: left; }
      .table td.tinytable_css_20asswrmt38h8iq37a68, .table th.tinytable_css_20asswrmt38h8iq37a68 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_znqx8uijkjsgy32d5jkd" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667 [3815.060, 12082.275]</td>
                  <td data-row="1" data-col="2">8.241 [8.230, 8.252]</td>
                  <td data-row="1" data-col="3">16259.384 [11065.933, 21452.836]</td>
                </tr>
<tr>
<td data-row="2" data-col="0">Literacy</td>
                  <td data-row="2" data-col="1">-39.121 [-112.816, 34.574]</td>
                  <td data-row="2" data-col="2">0.003 [0.003, 0.003]</td>
                  <td data-row="2" data-col="3">3.680 [-88.910, 96.270]</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Clergy</td>
                  <td data-row="3" data-col="1">15.257 [-35.930, 66.443]</td>
                  <td data-row="3" data-col="2"></td>
                  <td data-row="3" data-col="3">77.148 [12.837, 141.459]</td>
                </tr>
<tr>
<td data-row="4" data-col="0">Commerce</td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">0.011 [0.011, 0.011]</td>
                  <td data-row="4" data-col="3"></td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="vcov" class="level1"><h1><code>vcov</code></h1>
<p>You can use clustered or robust uncertainty estimates by modifying the <code>vcov</code> parameter. This function accepts 5 different types of input. You can use a string or a vector of strings:</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, vcov <span class="op">=</span> <span class="st">"robust"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, vcov <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"classical"</span>, <span class="st">"HC3"</span>, <span class="st">"bootstrap"</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>These variance-covariance matrices are calculated using the <code>sandwich</code> package. You can pass arguments to the <code>sandwich</code> functions directly from the <code>modelsummary</code> function. For instance, to change the number of bootstrap replicates and to specify a clustering variable we could call:</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, vcov <span class="op">=</span> <span class="st">"bootstrap"</span>, R <span class="op">=</span> <span class="fl">1000</span>, cluster <span class="op">=</span> <span class="st">"country"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>You can use a one-sided formula or list of one-sided formulas to use clustered standard errors:</p>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, vcov <span class="op">=</span> <span class="op">~</span><span class="va">Region</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>You can specify a function that produces variance-covariance matrices:</p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://sandwich.R-Forge.R-project.org/">sandwich</a></span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, vcov <span class="op">=</span> <span class="va">vcovHC</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>You can supply a list of functions of the same length as your model list:</p>
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, </span>
<span>  vcov <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="va">vcov</span>, <span class="va">vcovHC</span>, <span class="va">vcovHAC</span>, <span class="va">vcovHC</span>, <span class="va">vcov</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>You can supply a list of named variance-covariance matrices:</p>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">vcov_matrices</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="va">models</span>, <span class="va">vcovHC</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, vcov <span class="op">=</span> <span class="va">vcov_matrices</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>You can supply a list of named vectors:</p>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">vc</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  `OLS 1` <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>`(Intercept)` <span class="op">=</span> <span class="fl">2</span>, Literacy <span class="op">=</span> <span class="fl">3</span>, Clergy <span class="op">=</span> <span class="fl">4</span><span class="op">)</span>, </span>
<span>  `Poisson` <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>`(Intercept)` <span class="op">=</span> <span class="fl">3</span>, Literacy <span class="op">=</span> <span class="op">-</span><span class="fl">5</span>, Commerce <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>,</span>
<span>  `OLS 2` <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>`(Intercept)` <span class="op">=</span> <span class="fl">7</span>, Literacy <span class="op">=</span> <span class="op">-</span><span class="fl">6</span>, Clergy <span class="op">=</span> <span class="fl">9</span><span class="op">)</span></span>
<span>  <span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, vcov <span class="op">=</span> <span class="va">vc</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section><section id="stars" class="level1"><h1><code>stars</code></h1>
<p>Some people like to add “stars” to their model summary tables to mark statistical significance. The <code>stars</code> argument can take three types of input:</p>
<ol type="1">
<li>
<code>NULL</code> omits any stars or special marks (default)</li>
<li>
<code>TRUE</code> uses these default values: <code>+ p &lt; 0.1, * p &lt; 0.05, ** p &lt; 0.01, *** p &lt; 0.001</code>
</li>
<li>Named numeric vector for custom stars.</li>
</ol>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, stars <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> </span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, stars <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">'+'</span> <span class="op">=</span> <span class="fl">.1</span>, <span class="st">'&amp;'</span> <span class="op">=</span> <span class="fl">.01</span><span class="op">)</span><span class="op">)</span> </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>Whenever <code>stars</code> is not <code>NULL</code>, <code>modelsummary</code> adds a note at the bottom of the table automatically. If you would like to add stars but <em>not</em> include a note at the bottom of the table, you can define the display of your estimate manually using a <code>glue</code> string, as described in the <a href="https://modelsummary.com/vignettes/modelsummary.html#estimate-1"><code>estimate</code> argument section of the documentation.</a> Whenever the <a href="https://r-spatial.github.io/stars/">stars</a> string appears in the <code>estimate</code> or <code>statistic</code> arguments, <code>modelsummary</code> will assume that you want fine-grained control over your table, and will <em>not</em> include a note about stars.</p>
<div class="cell">
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>,</span>
<span>             estimate <span class="op">=</span> <span class="st">"{estimate}{stars}"</span>,</span>
<span>             gof_omit <span class="op">=</span> <span class="st">".*"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_zklj4jq6y00yogzmm2xc(i, j, css_id) {
          var table = document.getElementById("tinytable_zklj4jq6y00yogzmm2xc");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_zklj4jq6y00yogzmm2xc(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_zklj4jq6y00yogzmm2xc");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '8', j: 2 }, { i: '8', j: 1 }, { i: '8', j: 3 },  ], css_id: 'tinytable_css_to3eva60nrrykbxrwdek',}, 
          { positions: [ { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '3', j: 3 }, { i: '1', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '7', j: 3 }, { i: '5', j: 1 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '4', j: 3 }, { i: '5', j: 3 }, { i: '6', j: 3 },  ], css_id: 'tinytable_css_13g8m5virxccyvyv84qj',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_udzkniacaasg44i7v7ze',}, 
          { positions: [ { i: '8', j: 0 },  ], css_id: 'tinytable_css_6mq0xzthwvn4hgzoewkm',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 },  ], css_id: 'tinytable_css_f6zrxpwqfygma6qq4q7o',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_7bo1dccm2o92szpa3dvg',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_zklj4jq6y00yogzmm2xc(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_to3eva60nrrykbxrwdek, .table th.tinytable_css_to3eva60nrrykbxrwdek { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_13g8m5virxccyvyv84qj, .table th.tinytable_css_13g8m5virxccyvyv84qj { text-align: center; }
      .table td.tinytable_css_udzkniacaasg44i7v7ze, .table th.tinytable_css_udzkniacaasg44i7v7ze { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_6mq0xzthwvn4hgzoewkm, .table th.tinytable_css_6mq0xzthwvn4hgzoewkm { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_f6zrxpwqfygma6qq4q7o, .table th.tinytable_css_f6zrxpwqfygma6qq4q7o { text-align: left; }
      .table td.tinytable_css_7bo1dccm2o92szpa3dvg, .table th.tinytable_css_7bo1dccm2o92szpa3dvg { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_zklj4jq6y00yogzmm2xc" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667***</td>
                  <td data-row="1" data-col="2">8.241***</td>
                  <td data-row="1" data-col="3">16259.384***</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(2078.276)</td>
                  <td data-row="2" data-col="2">(0.006)</td>
                  <td data-row="2" data-col="3">(2611.140)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-39.121</td>
                  <td data-row="3" data-col="2">0.003***</td>
                  <td data-row="3" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(37.052)</td>
                  <td data-row="4" data-col="2">(0.000)</td>
                  <td data-row="4" data-col="3">(46.552)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Clergy</td>
                  <td data-row="5" data-col="1">15.257</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">77.148*</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(25.735)</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">(32.334)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Commerce</td>
                  <td data-row="7" data-col="1"></td>
                  <td data-row="7" data-col="2">0.011***</td>
                  <td data-row="7" data-col="3"></td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">(0.000)</td>
                  <td data-row="8" data-col="3"></td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>If you want to create your own stars description, you can add custom notes with the <a href="https://github.com/vincentarelbundock/modelsummary#notes"><code>notes</code></a> argument.</p>
</section><section id="coef_omit" class="level1"><h1><code>coef_omit</code></h1>
<p>An alternative mechanism to subset coefficients is to use the <code>coef_omit</code> argument, which accepts a vector of integer or a regular expression. For example, we can omit the first and second coefficients as follows:</p>
<div class="cell">
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, coef_omit <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">2</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_01p12us7vsjefwn6u4mq(i, j, css_id) {
          var table = document.getElementById("tinytable_01p12us7vsjefwn6u4mq");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_01p12us7vsjefwn6u4mq(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_01p12us7vsjefwn6u4mq");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 3 },  ], css_id: 'tinytable_css_jcnddqx03csuon684r5o',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '1', j: 2 }, { i: '1', j: 3 },  ], css_id: 'tinytable_css_aknjyvvyt1ojyk7mk1ly',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_0hwnc8prmk5lumx8tfms',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_iywmz9pad3haggu373va',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_869mund0sd3nyyrua53o',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_i4dufehdf18oqhyiffvh',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_01p12us7vsjefwn6u4mq(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_jcnddqx03csuon684r5o, .table th.tinytable_css_jcnddqx03csuon684r5o { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_aknjyvvyt1ojyk7mk1ly, .table th.tinytable_css_aknjyvvyt1ojyk7mk1ly { text-align: center; }
      .table td.tinytable_css_0hwnc8prmk5lumx8tfms, .table th.tinytable_css_0hwnc8prmk5lumx8tfms { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_iywmz9pad3haggu373va, .table th.tinytable_css_iywmz9pad3haggu373va { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_869mund0sd3nyyrua53o, .table th.tinytable_css_869mund0sd3nyyrua53o { text-align: left; }
      .table td.tinytable_css_i4dufehdf18oqhyiffvh, .table th.tinytable_css_i4dufehdf18oqhyiffvh { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_01p12us7vsjefwn6u4mq" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Clergy</td>
                  <td data-row="1" data-col="1">15.257</td>
                  <td data-row="1" data-col="2"></td>
                  <td data-row="1" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(25.735)</td>
                  <td data-row="2" data-col="2"></td>
                  <td data-row="2" data-col="3">(32.334)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Commerce</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2">0.011</td>
                  <td data-row="3" data-col="3"></td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">(0.000)</td>
                  <td data-row="4" data-col="3"></td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Negative indices determine which coefficients to <em>keep</em>:</p>
<div class="cell">
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, coef_omit <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="op">-</span><span class="fl">1</span>, <span class="op">-</span><span class="fl">2</span><span class="op">)</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_jmfupe1gfshwjiucyegn(i, j, css_id) {
          var table = document.getElementById("tinytable_jmfupe1gfshwjiucyegn");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_jmfupe1gfshwjiucyegn(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_jmfupe1gfshwjiucyegn");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 3 },  ], css_id: 'tinytable_css_86djdxxz09p90n252pnd',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '1', j: 2 }, { i: '1', j: 3 },  ], css_id: 'tinytable_css_6xgp7vtcowzgmizhwpwa',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_va1099pfadxtnvguuuuz',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_6bq03qnizmrjflfa6o6s',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_cu9qdp234pmnyi8t3ypp',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_pnkmi590o71ciifih1vs',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_jmfupe1gfshwjiucyegn(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_86djdxxz09p90n252pnd, .table th.tinytable_css_86djdxxz09p90n252pnd { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_6xgp7vtcowzgmizhwpwa, .table th.tinytable_css_6xgp7vtcowzgmizhwpwa { text-align: center; }
      .table td.tinytable_css_va1099pfadxtnvguuuuz, .table th.tinytable_css_va1099pfadxtnvguuuuz { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_6bq03qnizmrjflfa6o6s, .table th.tinytable_css_6bq03qnizmrjflfa6o6s { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_cu9qdp234pmnyi8t3ypp, .table th.tinytable_css_cu9qdp234pmnyi8t3ypp { text-align: left; }
      .table td.tinytable_css_pnkmi590o71ciifih1vs, .table th.tinytable_css_pnkmi590o71ciifih1vs { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_jmfupe1gfshwjiucyegn" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667</td>
                  <td data-row="1" data-col="2">8.241</td>
                  <td data-row="1" data-col="3">16259.384</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(2078.276)</td>
                  <td data-row="2" data-col="2">(0.006)</td>
                  <td data-row="2" data-col="3">(2611.140)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-39.121</td>
                  <td data-row="3" data-col="2">0.003</td>
                  <td data-row="3" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(37.052)</td>
                  <td data-row="4" data-col="2">(0.000)</td>
                  <td data-row="4" data-col="3">(46.552)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>When <code>coef_omit</code> is a string, it is fed to <code>grepl(x,perl=TRUE)</code> to detect the variable names which should be excluded from the table.</p>
<div class="cell">
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, coef_omit <span class="op">=</span> <span class="st">"Intercept|.*merce"</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_3uzh72mtdbhhlo17ubuw(i, j, css_id) {
          var table = document.getElementById("tinytable_3uzh72mtdbhhlo17ubuw");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_3uzh72mtdbhhlo17ubuw(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_3uzh72mtdbhhlo17ubuw");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 3 },  ], css_id: 'tinytable_css_sbxe6t4xt036745ss70u',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '1', j: 2 }, { i: '1', j: 3 },  ], css_id: 'tinytable_css_q9zb6wnmv53b1ao3na6r',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_s2hjmhphneaatr7vlcrp',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_9bk9vly47qsout5vltud',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_d4mfa44cy8wgr08o1wl0',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_195d4bz5e2a3n6666cvv',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_3uzh72mtdbhhlo17ubuw(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_sbxe6t4xt036745ss70u, .table th.tinytable_css_sbxe6t4xt036745ss70u { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_q9zb6wnmv53b1ao3na6r, .table th.tinytable_css_q9zb6wnmv53b1ao3na6r { text-align: center; }
      .table td.tinytable_css_s2hjmhphneaatr7vlcrp, .table th.tinytable_css_s2hjmhphneaatr7vlcrp { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_9bk9vly47qsout5vltud, .table th.tinytable_css_9bk9vly47qsout5vltud { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_d4mfa44cy8wgr08o1wl0, .table th.tinytable_css_d4mfa44cy8wgr08o1wl0 { text-align: left; }
      .table td.tinytable_css_195d4bz5e2a3n6666cvv, .table th.tinytable_css_195d4bz5e2a3n6666cvv { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_3uzh72mtdbhhlo17ubuw" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Literacy</td>
                  <td data-row="1" data-col="1">-39.121</td>
                  <td data-row="1" data-col="2">0.003</td>
                  <td data-row="1" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(37.052)</td>
                  <td data-row="2" data-col="2">(0.000)</td>
                  <td data-row="2" data-col="3">(46.552)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Clergy</td>
                  <td data-row="3" data-col="1">15.257</td>
                  <td data-row="3" data-col="2"></td>
                  <td data-row="3" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(25.735)</td>
                  <td data-row="4" data-col="2"></td>
                  <td data-row="4" data-col="3">(32.334)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Since <code>coef_omit</code> accepts regexes, you can do interesting things with it, such as specifying the list of variables that <code>modelsummary</code> should <em>keep</em> instead of omit. To do this, we use <a href="https://www.regular-expressions.info/lookaround.html">a negative lookahead.</a> To keep only the coefficients <em>starting</em> with “Lit”, we call:</p>
<div class="cell">
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, coef_omit <span class="op">=</span> <span class="st">"^(?!Lit)"</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_d27o9kf34iubl3ocz374(i, j, css_id) {
          var table = document.getElementById("tinytable_d27o9kf34iubl3ocz374");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_d27o9kf34iubl3ocz374(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_d27o9kf34iubl3ocz374");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '2', j: 2 }, { i: '2', j: 1 }, { i: '2', j: 3 },  ], css_id: 'tinytable_css_pqmb52gwlmcgywpjp6pj',}, 
          { positions: [ { i: '1', j: 1 }, { i: '1', j: 2 }, { i: '1', j: 3 },  ], css_id: 'tinytable_css_gkvgkhh4qysi80z2osu4',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_jse9a2m0bxnnz804f79i',}, 
          { positions: [ { i: '2', j: 0 },  ], css_id: 'tinytable_css_glail0iwkkq173uy7fp1',}, 
          { positions: [ { i: '1', j: 0 },  ], css_id: 'tinytable_css_g1jfgzy3az3w0itr6vvn',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_kuugi1iq2bolzqwcafcy',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_d27o9kf34iubl3ocz374(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_pqmb52gwlmcgywpjp6pj, .table th.tinytable_css_pqmb52gwlmcgywpjp6pj { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_gkvgkhh4qysi80z2osu4, .table th.tinytable_css_gkvgkhh4qysi80z2osu4 { text-align: center; }
      .table td.tinytable_css_jse9a2m0bxnnz804f79i, .table th.tinytable_css_jse9a2m0bxnnz804f79i { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_glail0iwkkq173uy7fp1, .table th.tinytable_css_glail0iwkkq173uy7fp1 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_g1jfgzy3az3w0itr6vvn, .table th.tinytable_css_g1jfgzy3az3w0itr6vvn { text-align: left; }
      .table td.tinytable_css_kuugi1iq2bolzqwcafcy, .table th.tinytable_css_kuugi1iq2bolzqwcafcy { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_d27o9kf34iubl3ocz374" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Literacy</td>
                  <td data-row="1" data-col="1">-39.121</td>
                  <td data-row="1" data-col="2">0.003</td>
                  <td data-row="1" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(37.052)</td>
                  <td data-row="2" data-col="2">(0.000)</td>
                  <td data-row="2" data-col="3">(46.552)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>To keep all coefficients matching the “y” substring:</p>
<div class="cell">
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, coef_omit <span class="op">=</span> <span class="st">"^(?!.*y)"</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_5dpygwjqgplh9hj2k96e(i, j, css_id) {
          var table = document.getElementById("tinytable_5dpygwjqgplh9hj2k96e");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_5dpygwjqgplh9hj2k96e(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_5dpygwjqgplh9hj2k96e");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 }, { i: '4', j: 3 },  ], css_id: 'tinytable_css_jju2ou61346z3t3d48vw',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '1', j: 2 }, { i: '1', j: 3 },  ], css_id: 'tinytable_css_bz5h4rsxbzy69yds1wr6',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_x42oafyda3zkykjv7am3',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_t8fwssfwrkuprp5m3ils',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 },  ], css_id: 'tinytable_css_35wk0snjfsw59rjdm1an',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_fgww8bqv6w22dqb7w755',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_5dpygwjqgplh9hj2k96e(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_jju2ou61346z3t3d48vw, .table th.tinytable_css_jju2ou61346z3t3d48vw { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_bz5h4rsxbzy69yds1wr6, .table th.tinytable_css_bz5h4rsxbzy69yds1wr6 { text-align: center; }
      .table td.tinytable_css_x42oafyda3zkykjv7am3, .table th.tinytable_css_x42oafyda3zkykjv7am3 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_t8fwssfwrkuprp5m3ils, .table th.tinytable_css_t8fwssfwrkuprp5m3ils { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_35wk0snjfsw59rjdm1an, .table th.tinytable_css_35wk0snjfsw59rjdm1an { text-align: left; }
      .table td.tinytable_css_fgww8bqv6w22dqb7w755, .table th.tinytable_css_fgww8bqv6w22dqb7w755 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_5dpygwjqgplh9hj2k96e" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Literacy</td>
                  <td data-row="1" data-col="1">-39.121</td>
                  <td data-row="1" data-col="2">0.003</td>
                  <td data-row="1" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(37.052)</td>
                  <td data-row="2" data-col="2">(0.000)</td>
                  <td data-row="2" data-col="3">(46.552)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Clergy</td>
                  <td data-row="3" data-col="1">15.257</td>
                  <td data-row="3" data-col="2"></td>
                  <td data-row="3" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(25.735)</td>
                  <td data-row="4" data-col="2"></td>
                  <td data-row="4" data-col="3">(32.334)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>To keep all coefficients matching one of two substrings:</p>
<div class="cell">
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, coef_omit <span class="op">=</span> <span class="st">"^(?!.*tercept|.*y)"</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_8pblr2e0t4yv4n7s9zhk(i, j, css_id) {
          var table = document.getElementById("tinytable_8pblr2e0t4yv4n7s9zhk");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_8pblr2e0t4yv4n7s9zhk(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_8pblr2e0t4yv4n7s9zhk");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '6', j: 2 }, { i: '6', j: 1 }, { i: '6', j: 3 },  ], css_id: 'tinytable_css_qdxmwa33ru18y3gkue76',}, 
          { positions: [ { i: '1', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '3', j: 3 }, { i: '4', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '5', j: 3 },  ], css_id: 'tinytable_css_1wyzvco7pqid38dbk8vv',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_gus7bj5o1kbwqg4880fk',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_qzg8ifm1a7p4y9ende9o',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 },  ], css_id: 'tinytable_css_9y34ot4jpo7ppgfft0vp',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_2bzjtx5so3h3281kvvw2',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_8pblr2e0t4yv4n7s9zhk(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_qdxmwa33ru18y3gkue76, .table th.tinytable_css_qdxmwa33ru18y3gkue76 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_1wyzvco7pqid38dbk8vv, .table th.tinytable_css_1wyzvco7pqid38dbk8vv { text-align: center; }
      .table td.tinytable_css_gus7bj5o1kbwqg4880fk, .table th.tinytable_css_gus7bj5o1kbwqg4880fk { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_qzg8ifm1a7p4y9ende9o, .table th.tinytable_css_qzg8ifm1a7p4y9ende9o { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_9y34ot4jpo7ppgfft0vp, .table th.tinytable_css_9y34ot4jpo7ppgfft0vp { text-align: left; }
      .table td.tinytable_css_2bzjtx5so3h3281kvvw2, .table th.tinytable_css_2bzjtx5so3h3281kvvw2 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_8pblr2e0t4yv4n7s9zhk" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667</td>
                  <td data-row="1" data-col="2">8.241</td>
                  <td data-row="1" data-col="3">16259.384</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(2078.276)</td>
                  <td data-row="2" data-col="2">(0.006)</td>
                  <td data-row="2" data-col="3">(2611.140)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-39.121</td>
                  <td data-row="3" data-col="2">0.003</td>
                  <td data-row="3" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(37.052)</td>
                  <td data-row="4" data-col="2">(0.000)</td>
                  <td data-row="4" data-col="3">(46.552)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Clergy</td>
                  <td data-row="5" data-col="1">15.257</td>
                  <td data-row="5" data-col="2"></td>
                  <td data-row="5" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(25.735)</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">(32.334)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="coef_rename" class="level1"><h1><code>coef_rename</code></h1>
<p><code>modelsummary</code> offers powerful and innovative mechanisms to rename, reorder, and subset coefficients and goodness-of-fit statistics.</p>
<p>You can rename coefficients using the <code>coef_rename</code> argument. For example, if you have two models with different explanatory variables, but you want both variables to have the same name and appear on the same row, you can do:</p>
<div class="cell">
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>          <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">vs</span>, <span class="va">mtcars</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">x</span>, coef_rename <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"drat"</span> <span class="op">=</span> <span class="st">"Explanator"</span>, <span class="st">"vs"</span> <span class="op">=</span> <span class="st">"Explanator"</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_dlaheapaoaiceaxecfom(i, j, css_id) {
          var table = document.getElementById("tinytable_dlaheapaoaiceaxecfom");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_dlaheapaoaiceaxecfom(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_dlaheapaoaiceaxecfom");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '12', j: 1 }, { i: '12', j: 2 },  ], css_id: 'tinytable_css_89c23raf6ytd84a599gf',}, 
          { positions: [ { i: '4', j: 1 }, { i: '4', j: 2 },  ], css_id: 'tinytable_css_01x0z2mrq91q8ccc8kwf',}, 
          { positions: [ { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '8', j: 1 }, { i: '1', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '3', j: 2 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '7', j: 2 }, { i: '9', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '11', j: 2 }, { i: '8', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 },  ], css_id: 'tinytable_css_9aqos2t4rbe6od2jbmop',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_jmp8jk111jz3t5ey1cfw',}, 
          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_krfvpfngaxypaqr3pppo',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_4bxo7lix1gnyw1uw7h24',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 },  ], css_id: 'tinytable_css_acpy13fefv9zodto3y8d',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_rrb0tuqwrmkoycdwdn85',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_dlaheapaoaiceaxecfom(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_89c23raf6ytd84a599gf, .table th.tinytable_css_89c23raf6ytd84a599gf { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_01x0z2mrq91q8ccc8kwf, .table th.tinytable_css_01x0z2mrq91q8ccc8kwf { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_9aqos2t4rbe6od2jbmop, .table th.tinytable_css_9aqos2t4rbe6od2jbmop { text-align: center; }
      .table td.tinytable_css_jmp8jk111jz3t5ey1cfw, .table th.tinytable_css_jmp8jk111jz3t5ey1cfw { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_krfvpfngaxypaqr3pppo, .table th.tinytable_css_krfvpfngaxypaqr3pppo { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_4bxo7lix1gnyw1uw7h24, .table th.tinytable_css_4bxo7lix1gnyw1uw7h24 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_acpy13fefv9zodto3y8d, .table th.tinytable_css_acpy13fefv9zodto3y8d { text-align: left; }
      .table td.tinytable_css_rrb0tuqwrmkoycdwdn85, .table th.tinytable_css_rrb0tuqwrmkoycdwdn85 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_dlaheapaoaiceaxecfom" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">353.653</td>
                  <td data-row="1" data-col="2">189.722</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(76.049)</td>
                  <td data-row="2" data-col="2">(11.347)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Explanator</td>
                  <td data-row="3" data-col="1">-57.545</td>
                  <td data-row="3" data-col="2">-98.365</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(20.922)</td>
                  <td data-row="4" data-col="2">(17.155)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                  <td data-row="5" data-col="2">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2</td>
                  <td data-row="6" data-col="1">0.201</td>
                  <td data-row="6" data-col="2">0.523</td>
                </tr>
<tr>
<td data-row="7" data-col="0">R2 Adj.</td>
                  <td data-row="7" data-col="1">0.175</td>
                  <td data-row="7" data-col="2">0.507</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">359.2</td>
                  <td data-row="8" data-col="2">342.7</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">363.6</td>
                  <td data-row="9" data-col="2">347.1</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-176.588</td>
                  <td data-row="10" data-col="2">-168.347</td>
                </tr>
<tr>
<td data-row="11" data-col="0">F</td>
                  <td data-row="11" data-col="1">7.565</td>
                  <td data-row="11" data-col="2">32.876</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1">60.31</td>
                  <td data-row="12" data-col="2">46.61</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>If you provide a named character vector to <code>coef_rename</code>, only exact matches of the <em>complete</em> original term name will be replaced.</p>
<p>For complex modifications, you can feed a function which returns a named vector to the <code>coef_rename</code> argument. For example, <code>modelsummary</code> ships with a function called <code>coef_rename</code>, which executes some common renaming tasks automatically. This example also uses the <code>dvnames</code> function to extract the name of the dependent variable in each model:</p>
<div class="cell">
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span> <span class="op">+</span> <span class="va">drat</span> <span class="op">+</span> <span class="va">disp</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span> <span class="op">+</span> <span class="va">drat</span> <span class="op">+</span> <span class="va">disp</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="fu"><a href="https://modelsummary.com/man/dvnames.html">dvnames</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>, coef_rename <span class="op">=</span> <span class="va">coef_rename</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_a17y7wbig1h4zvnp0msf(i, j, css_id) {
          var table = document.getElementById("tinytable_a17y7wbig1h4zvnp0msf");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_a17y7wbig1h4zvnp0msf(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_a17y7wbig1h4zvnp0msf");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '18', j: 1 }, { i: '18', j: 2 },  ], css_id: 'tinytable_css_546krdumvt1kjagere7f',}, 
          { positions: [ { i: '10', j: 2 }, { i: '10', j: 1 },  ], css_id: 'tinytable_css_9wvytolyigp0u9gl7ufq',}, 
          { positions: [ { i: '1', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '2', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '4', j: 2 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '16', j: 1 }, { i: '17', j: 1 }, { i: '12', j: 2 }, { i: '6', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '17', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '14', j: 2 }, { i: '11', j: 2 }, { i: '16', j: 2 }, { i: '13', j: 2 }, { i: '15', j: 2 },  ], css_id: 'tinytable_css_ugxmdjuafh4jvjr3r62b',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_kmftjqedia4pwzdfon66',}, 
          { positions: [ { i: '18', j: 0 },  ], css_id: 'tinytable_css_hrwss7jmoruxm8cunp65',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_un0qxsv5k4bmgw7yeytm',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '15', j: 0 }, { i: '16', j: 0 }, { i: '17', j: 0 },  ], css_id: 'tinytable_css_qkh2p10ac9ji8im3ia63',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_r5k2mjy38ftdgryj63hf',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_a17y7wbig1h4zvnp0msf(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_546krdumvt1kjagere7f, .table th.tinytable_css_546krdumvt1kjagere7f { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_9wvytolyigp0u9gl7ufq, .table th.tinytable_css_9wvytolyigp0u9gl7ufq { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_ugxmdjuafh4jvjr3r62b, .table th.tinytable_css_ugxmdjuafh4jvjr3r62b { text-align: center; }
      .table td.tinytable_css_kmftjqedia4pwzdfon66, .table th.tinytable_css_kmftjqedia4pwzdfon66 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_hrwss7jmoruxm8cunp65, .table th.tinytable_css_hrwss7jmoruxm8cunp65 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_un0qxsv5k4bmgw7yeytm, .table th.tinytable_css_un0qxsv5k4bmgw7yeytm { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_qkh2p10ac9ji8im3ia63, .table th.tinytable_css_qkh2p10ac9ji8im3ia63 { text-align: left; }
      .table td.tinytable_css_r5k2mjy38ftdgryj63hf, .table th.tinytable_css_r5k2mjy38ftdgryj63hf { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_a17y7wbig1h4zvnp0msf" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">mpg</th>
                <th scope="col" data-row="0" data-col="2">hp</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">26.158</td>
                  <td data-row="1" data-col="2">-86.788</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(6.537)</td>
                  <td data-row="2" data-col="2">(79.395)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">6</td>
                  <td data-row="3" data-col="1">-4.547</td>
                  <td data-row="3" data-col="2">46.485</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(1.731)</td>
                  <td data-row="4" data-col="2">(21.027)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">8</td>
                  <td data-row="5" data-col="1">-4.580</td>
                  <td data-row="5" data-col="2">121.892</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(2.952)</td>
                  <td data-row="6" data-col="2">(35.853)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Drat</td>
                  <td data-row="7" data-col="1">0.783</td>
                  <td data-row="7" data-col="2">37.815</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1">(1.478)</td>
                  <td data-row="8" data-col="2">(17.952)</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Disp</td>
                  <td data-row="9" data-col="1">-0.026</td>
                  <td data-row="9" data-col="2">0.147</td>
                </tr>
<tr>
<td data-row="10" data-col="0"></td>
                  <td data-row="10" data-col="1">(0.011)</td>
                  <td data-row="10" data-col="2">(0.137)</td>
                </tr>
<tr>
<td data-row="11" data-col="0">Num.Obs.</td>
                  <td data-row="11" data-col="1">32</td>
                  <td data-row="11" data-col="2">32</td>
                </tr>
<tr>
<td data-row="12" data-col="0">R2</td>
                  <td data-row="12" data-col="1">0.786</td>
                  <td data-row="12" data-col="2">0.756</td>
                </tr>
<tr>
<td data-row="13" data-col="0">R2 Adj.</td>
                  <td data-row="13" data-col="1">0.754</td>
                  <td data-row="13" data-col="2">0.720</td>
                </tr>
<tr>
<td data-row="14" data-col="0">AIC</td>
                  <td data-row="14" data-col="1">167.4</td>
                  <td data-row="14" data-col="2">327.2</td>
                </tr>
<tr>
<td data-row="15" data-col="0">BIC</td>
                  <td data-row="15" data-col="1">176.2</td>
                  <td data-row="15" data-col="2">336.0</td>
                </tr>
<tr>
<td data-row="16" data-col="0">Log.Lik.</td>
                  <td data-row="16" data-col="1">-77.719</td>
                  <td data-row="16" data-col="2">-157.623</td>
                </tr>
<tr>
<td data-row="17" data-col="0">F</td>
                  <td data-row="17" data-col="1">24.774</td>
                  <td data-row="17" data-col="2">20.903</td>
                </tr>
<tr>
<td data-row="18" data-col="0">RMSE</td>
                  <td data-row="18" data-col="1">2.74</td>
                  <td data-row="18" data-col="2">33.34</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Of course, you can also define your own custom functions. For instance, to rename a model with interacted variables (e.g., “drat:mpg”), you could define a custom <code>rename_explanator</code> function:</p>
<div class="cell">
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">y</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">drat</span> <span class="op">/</span> <span class="va">mpg</span>, <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">vs</span> <span class="op">/</span> <span class="va">mpg</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="va">rename_explanator</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">old_names</span><span class="op">)</span> <span class="op">{</span></span>
<span>  <span class="va">new_names</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/grep.html">gsub</a></span><span class="op">(</span><span class="st">"drat|vs"</span>, <span class="st">"Explanator"</span>, <span class="va">old_names</span><span class="op">)</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/setNames.html">setNames</a></span><span class="op">(</span><span class="va">new_names</span>, <span class="va">old_names</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">y</span>, coef_rename <span class="op">=</span> <span class="va">rename_explanator</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_eurlj1zqlq6kmpcqjubg(i, j, css_id) {
          var table = document.getElementById("tinytable_eurlj1zqlq6kmpcqjubg");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_eurlj1zqlq6kmpcqjubg(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_eurlj1zqlq6kmpcqjubg");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '14', j: 1 }, { i: '14', j: 2 },  ], css_id: 'tinytable_css_zqig6i8mm2sip1kkk6yh',}, 
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 },  ], css_id: 'tinytable_css_wz5m1s4w0igdcaen1rrl',}, 
          { positions: [ { i: '1', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '4', j: 2 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '12', j: 2 }, { i: '2', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '8', j: 2 }, { i: '5', j: 2 }, { i: '10', j: 2 }, { i: '7', j: 2 }, { i: '9', j: 2 }, { i: '11', j: 2 }, { i: '13', j: 2 },  ], css_id: 'tinytable_css_x6ry1dsco50xfwfz0nlv',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_zvqbqjjvolk3pie9crd2',}, 
          { positions: [ { i: '14', j: 0 },  ], css_id: 'tinytable_css_pmx6305rp130ypi2889z',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_zkjdao3ab8atseehpc2z',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_zv43vew4va1ywl5k6952',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_bzjpwqmbg1hvqb2cwhqo',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_eurlj1zqlq6kmpcqjubg(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_zqig6i8mm2sip1kkk6yh, .table th.tinytable_css_zqig6i8mm2sip1kkk6yh { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_wz5m1s4w0igdcaen1rrl, .table th.tinytable_css_wz5m1s4w0igdcaen1rrl { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_x6ry1dsco50xfwfz0nlv, .table th.tinytable_css_x6ry1dsco50xfwfz0nlv { text-align: center; }
      .table td.tinytable_css_zvqbqjjvolk3pie9crd2, .table th.tinytable_css_zvqbqjjvolk3pie9crd2 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_pmx6305rp130ypi2889z, .table th.tinytable_css_pmx6305rp130ypi2889z { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_zkjdao3ab8atseehpc2z, .table th.tinytable_css_zkjdao3ab8atseehpc2z { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_zv43vew4va1ywl5k6952, .table th.tinytable_css_zv43vew4va1ywl5k6952 { text-align: left; }
      .table td.tinytable_css_bzjpwqmbg1hvqb2cwhqo, .table th.tinytable_css_bzjpwqmbg1hvqb2cwhqo { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_eurlj1zqlq6kmpcqjubg" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">91.206</td>
                  <td data-row="1" data-col="2">189.722</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(72.344)</td>
                  <td data-row="2" data-col="2">(11.205)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Explanator</td>
                  <td data-row="3" data-col="1">68.331</td>
                  <td data-row="3" data-col="2">-18.316</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(27.390)</td>
                  <td data-row="4" data-col="2">(62.531)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Explanator:mpg</td>
                  <td data-row="5" data-col="1">-2.558</td>
                  <td data-row="5" data-col="2">-3.260</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.467)</td>
                  <td data-row="6" data-col="2">(2.451)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                  <td data-row="7" data-col="2">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.608</td>
                  <td data-row="8" data-col="2">0.550</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.581</td>
                  <td data-row="9" data-col="2">0.519</td>
                </tr>
<tr>
<td data-row="10" data-col="0">AIC</td>
                  <td data-row="10" data-col="1">338.4</td>
                  <td data-row="10" data-col="2">342.8</td>
                </tr>
<tr>
<td data-row="11" data-col="0">BIC</td>
                  <td data-row="11" data-col="1">344.3</td>
                  <td data-row="11" data-col="2">348.7</td>
                </tr>
<tr>
<td data-row="12" data-col="0">Log.Lik.</td>
                  <td data-row="12" data-col="1">-165.218</td>
                  <td data-row="12" data-col="2">-167.399</td>
                </tr>
<tr>
<td data-row="13" data-col="0">F</td>
                  <td data-row="13" data-col="1">22.454</td>
                  <td data-row="13" data-col="2">17.743</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">42.27</td>
                  <td data-row="14" data-col="2">45.25</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Beware of inadvertently replacing parts of other variable names! Making your regex pattern as specific as possible (e.g., by adding word boundaries) is likely a good idea. The custom rename function is also a good place to re-introduce the replacement of “:” with “×” if you are dealing with interaction terms – <code>modelsummary</code> makes this replacement for you only when the <code>coef_rename</code> argument is not specified.</p>
<p>Another possibility is to assign variable labels to attributes in the data used to fit the model. Then, we can automatically rename them:</p>
<div class="cell">
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">datlab</span> <span class="op">&lt;-</span> <span class="va">mtcars</span></span>
<span><span class="va">datlab</span><span class="op">$</span><span class="va">cyl</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">datlab</span><span class="op">$</span><span class="va">cyl</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/attr.html">attr</a></span><span class="op">(</span><span class="va">datlab</span><span class="op">$</span><span class="va">cyl</span>, <span class="st">"label"</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="st">"Cylinders"</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/attr.html">attr</a></span><span class="op">(</span><span class="va">datlab</span><span class="op">$</span><span class="va">am</span>, <span class="st">"label"</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="st">"Transmission"</span></span>
<span><span class="va">modlab</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">cyl</span> <span class="op">+</span> <span class="va">am</span>, data <span class="op">=</span> <span class="va">datlab</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">modlab</span>, coef_rename <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_96whhb26ra8m6pb6kn7z(i, j, css_id) {
          var table = document.getElementById("tinytable_96whhb26ra8m6pb6kn7z");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_96whhb26ra8m6pb6kn7z(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_96whhb26ra8m6pb6kn7z");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 },  ], css_id: 'tinytable_css_t2z19bdic5q7tranwy5m',}, 
          { positions: [ { i: '8', j: 1 },  ], css_id: 'tinytable_css_ij7m9bzjne5j0dk8hcz6',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '12', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 },  ], css_id: 'tinytable_css_b0bob6r9655qksp7jj95',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_wthx2y7lih8cnsbp0hel',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_0i0c00zbgx198mhdchpm',}, 
          { positions: [ { i: '8', j: 0 },  ], css_id: 'tinytable_css_9h9vr27vp8nc3mnzf2du',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '12', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_fr0u7jrtegf5c4lhkkhr',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_qvmkvuv4xpq0jmkr2wq1',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_96whhb26ra8m6pb6kn7z(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_t2z19bdic5q7tranwy5m, .table th.tinytable_css_t2z19bdic5q7tranwy5m { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ij7m9bzjne5j0dk8hcz6, .table th.tinytable_css_ij7m9bzjne5j0dk8hcz6 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_b0bob6r9655qksp7jj95, .table th.tinytable_css_b0bob6r9655qksp7jj95 { text-align: center; }
      .table td.tinytable_css_wthx2y7lih8cnsbp0hel, .table th.tinytable_css_wthx2y7lih8cnsbp0hel { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_0i0c00zbgx198mhdchpm, .table th.tinytable_css_0i0c00zbgx198mhdchpm { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_9h9vr27vp8nc3mnzf2du, .table th.tinytable_css_9h9vr27vp8nc3mnzf2du { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_fr0u7jrtegf5c4lhkkhr, .table th.tinytable_css_fr0u7jrtegf5c4lhkkhr { text-align: left; }
      .table td.tinytable_css_qvmkvuv4xpq0jmkr2wq1, .table th.tinytable_css_qvmkvuv4xpq0jmkr2wq1 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_96whhb26ra8m6pb6kn7z" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">24.802</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(1.323)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Cylinders [6]</td>
                  <td data-row="3" data-col="1">-6.156</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(1.536)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Cylinders [8]</td>
                  <td data-row="5" data-col="1">-10.068</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(1.452)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Transmission</td>
                  <td data-row="7" data-col="1">2.560</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1">(1.298)</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Num.Obs.</td>
                  <td data-row="9" data-col="1">32</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2</td>
                  <td data-row="10" data-col="1">0.765</td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Adj.</td>
                  <td data-row="11" data-col="1">0.740</td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">168.4</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">175.7</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Log.Lik.</td>
                  <td data-row="14" data-col="1">-79.199</td>
                </tr>
<tr>
<td data-row="15" data-col="0">F</td>
                  <td data-row="15" data-col="1">30.402</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">2.87</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="coef_map" class="level1"><h1><code>coef_map</code></h1>
<p>The <code>coef_map</code> argument is a character vector which allows users to rename, reorder, and subset coefficient estimates. This vector <em>may</em> be named.</p>
<p>If the vector is named:</p>
<ul>
<li>If <code>coef_rename</code> equals <code>FALSE</code>, the names of this vector must be a subset of the variable names as returned by <code>modelsummary::get_estimates(mod)$term</code>.</li>
<li>If <code>coef_rename</code> equals <code>TRUE</code>, the names of this vector must be a subset of the variable labels as returned by <code>modelsummary::get_estimates(mod, coef_rename=TRUE)$term</code>.</li>
<li>The values of this vector correspond to new variable labels as they will appear in the output table (so, if <code>coef_rename</code> equals <code>TRUE</code>, the variables are basically renamed two times).</li>
</ul>
<p>If the vector is not named:</p>
<ul>
<li>If <code>coef_rename</code> equals <code>FALSE</code>, the values of this vector must be a subset of the variable names as returned by <code>modelsummary::get_estimates(mod)$term</code>.</li>
<li>If <code>coef_rename</code> equals <code>TRUE</code>, the values of this vector must be a subset of the variable labels as returned by <code>modelsummary::get_estimates(mod, coef_rename=TRUE)$term</code>.</li>
</ul>
<p>The output table will be sorted in the order in which terms are presented in <code>coef_map</code>. Coefficients which are <em>not</em> included in <code>coef_map</code> will be excluded from the table.</p>
<p>Here is an example in which only the variables <code>disp</code>, <code>hp</code> and <code>qsec</code> are shown in the output table. The variables <code>vs</code>, <code>am</code> as well as the intercept are not shown:</p>
<div class="cell">
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod1</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">disp</span> <span class="op">+</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">qsec</span> <span class="op">+</span> <span class="va">vs</span> <span class="op">+</span> <span class="va">am</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">mod1</span>,</span>
<span>  coef_map <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"disp"</span>, <span class="st">"hp"</span>, <span class="st">"qsec"</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_p581x47y2lp9mt4ws2gm(i, j, css_id) {
          var table = document.getElementById("tinytable_p581x47y2lp9mt4ws2gm");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_p581x47y2lp9mt4ws2gm(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_p581x47y2lp9mt4ws2gm");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '14', j: 1 },  ], css_id: 'tinytable_css_ll15jwa9frvhzbwhfwg5',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_e2f3txtxfsvb3su0ls50',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 },  ], css_id: 'tinytable_css_z1ldwj4n0f0jo5dyjaml',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_w68gv5nwi6oj8xbxal91',}, 
          { positions: [ { i: '14', j: 0 },  ], css_id: 'tinytable_css_j3k6dnnmv3adoviqycaq',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_e82ok2eg8f2jor7aytgz',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_c63ufkwv7zqywqy77imj',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_2who2px5j88698whldr3',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_p581x47y2lp9mt4ws2gm(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_ll15jwa9frvhzbwhfwg5, .table th.tinytable_css_ll15jwa9frvhzbwhfwg5 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_e2f3txtxfsvb3su0ls50, .table th.tinytable_css_e2f3txtxfsvb3su0ls50 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_z1ldwj4n0f0jo5dyjaml, .table th.tinytable_css_z1ldwj4n0f0jo5dyjaml { text-align: center; }
      .table td.tinytable_css_w68gv5nwi6oj8xbxal91, .table th.tinytable_css_w68gv5nwi6oj8xbxal91 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_j3k6dnnmv3adoviqycaq, .table th.tinytable_css_j3k6dnnmv3adoviqycaq { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_e82ok2eg8f2jor7aytgz, .table th.tinytable_css_e82ok2eg8f2jor7aytgz { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_c63ufkwv7zqywqy77imj, .table th.tinytable_css_c63ufkwv7zqywqy77imj { text-align: left; }
      .table td.tinytable_css_2who2px5j88698whldr3, .table th.tinytable_css_2who2px5j88698whldr3 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_p581x47y2lp9mt4ws2gm" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">disp</td>
                  <td data-row="1" data-col="1">-0.008</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.010)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">-0.038</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.017)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">qsec</td>
                  <td data-row="5" data-col="1">-0.035</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.624)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.810</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.774</td>
                </tr>
<tr>
<td data-row="10" data-col="0">AIC</td>
                  <td data-row="10" data-col="1">165.5</td>
                </tr>
<tr>
<td data-row="11" data-col="0">BIC</td>
                  <td data-row="11" data-col="1">175.8</td>
                </tr>
<tr>
<td data-row="12" data-col="0">Log.Lik.</td>
                  <td data-row="12" data-col="1">-75.772</td>
                </tr>
<tr>
<td data-row="13" data-col="0">F</td>
                  <td data-row="13" data-col="1">22.227</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">2.58</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>We can re-label the variables in the output table. Notice that <code>coef_rename=FALSE</code>, is the default value:</p>
<pre><code>modelsummary(
  mod1,
  coef_rename = FALSE, # this is the default value
  coef_map = c(
    disp = "displacement",
    hp = "horsepower",
    qsec = "time"
  )
)</code></pre>
<p>Or we can label the variables in the dataframe. In this case, we use <code>coef_rename=TRUE</code> and pass to <code>coef_map</code> an un-named vector of variable labels:</p>
<pre><code>df &lt;- mtcars
df &lt;- labelled::set_variable_labels(
  df,
  .strict = FALSE,
  mpg = "Miles per gallon",
  disp = "Displacement (cu.in.)",
  hp = "Gross horsepower",
  qsec = "1/4 mile time",
  vs = "Engine type (0 = V/S, 1 = straight)",
  am = "Transmission (0 = automatic, 1 = manual)"
)
mod1 &lt;- lm(mpg ~ disp + hp + qsec + vs + am, data = df)
modelsummary(
  mod1,
  coef_rename = TRUE,
  coef_map = c("Displacement (cu.in.)", "Gross horsepower", "1/4 mile time")
)</code></pre>
<p>Or we can pass a named vector to re-label the variables once more:</p>
<pre><code>modelsummary(
  mod1,
  coef_rename = TRUE,
  coef_map = c(
    "Displacement (cu.in.)" = "displacement",
    "Gross horsepower" = "horsepower",
    "1/4 mile time" = "time"
  )
)</code></pre>
<p>Here is an example of a table displaying two models. The variables are sorted as follows: the variables which are only in the first model but not in the second, the variables which are only in the second model but not in the first, the variables which are common between the two models, then the intercept:</p>
<pre><code># Estimate the models
mod1 &lt;- lm(mpg ~ disp + hp + qsec + vs + am, data = mtcars)
mod2 &lt;- lm(cyl ~ drat + wt + qsec + vs + am, data = mtcars)

# Get coefficients of the two models
coefs1 &lt;- modelsummary::get_estimates(mod1)$term
coefs2 &lt;- modelsummary::get_estimates(mod2)$term

# Get the coefficients in common
coefs_common &lt;- intersect(coefs1, coefs2)

# Get the coefficients not in common
coefs1 &lt;- setdiff(coefs1, coefs_common)
coefs2 &lt;- setdiff(coefs2, coefs_common)

# Build `coef_map`
coef_map &lt;- c(coefs1, coefs2, coefs_common)
# Move the intercept at the end
coef_map &lt;- c(coef_map %&gt;% {.[.!="(Intercept)"]}, "(Intercept)")

# Display output table
modelsummary(
  list(mod1, mod2),
  coef_map = coef_map
)</code></pre>
</section><section id="gof_omit" class="level1"><h1><code>gof_omit</code></h1>
<p><code>gof_omit</code> is a regular expression which will be fed to <code>grepl(x,perl=TRUE)</code> to detect the names of the statistics which should be excluded from the table.</p>
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, gof_omit <span class="op">=</span> <span class="st">'DF|Deviance|R2|AIC|BIC'</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section><section id="gof_map" class="level1"><h1><code>gof_map</code></h1>
<p>The <code>gof_map</code> argument can be used to rename, re-order, subset, and format the statistics displayed in the bottom section of the table (“goodness-of-fit”).</p>
<p>There are three accepted types: a character vector, a dataframe/tibble, or a list.</p>
<p>The first type of allowed value is a character vector. This vector <em>may</em> be named. If it is named, the names are ignored (i.e., you cannot rename goodness-of-fit statistics with this type of value). The values of the vector <em>must</em> be a subset of <code>colnames(modelsummary::get_gof(model))</code>. Invalid values are silently ignored. Only the statistics in this vector will be printed in the output vector, in the order in which they appear in the vector:</p>
<p>Here is an example which prints only the number of observations, the AIC and the BIC as goodness-of-fit statistics. The other goodness-of-fit statistics returned by the model (i.e., <span class="math inline">\(R^2\)</span>) are discarded.</p>
<div class="cell">
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod1</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">disp</span> <span class="op">+</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">qsec</span> <span class="op">+</span> <span class="va">vs</span> <span class="op">+</span> <span class="va">am</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">mod1</span>,</span>
<span>  gof_map <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"nobs"</span>, <span class="st">"aic"</span>, <span class="st">"bic"</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_1shnr6huwzqle0ev3ewr(i, j, css_id) {
          var table = document.getElementById("tinytable_1shnr6huwzqle0ev3ewr");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_1shnr6huwzqle0ev3ewr(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_1shnr6huwzqle0ev3ewr");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '15', j: 1 },  ], css_id: 'tinytable_css_2wq8j30mmebk2m6zp4gr',}, 
          { positions: [ { i: '12', j: 1 },  ], css_id: 'tinytable_css_28flamrv5aukkllvypa6',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 },  ], css_id: 'tinytable_css_srijzo29phbygeiqwipx',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_6yjs0eplx6e07zpy2xi7',}, 
          { positions: [ { i: '15', j: 0 },  ], css_id: 'tinytable_css_db1nsd4npf74njlbdpl0',}, 
          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_y8myxteircswz8f36x8b',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 },  ], css_id: 'tinytable_css_z4cwybpe4i62j6nuup6e',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_2zrmiift65d1dl3j6xzf',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_1shnr6huwzqle0ev3ewr(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_2wq8j30mmebk2m6zp4gr, .table th.tinytable_css_2wq8j30mmebk2m6zp4gr { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_28flamrv5aukkllvypa6, .table th.tinytable_css_28flamrv5aukkllvypa6 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_srijzo29phbygeiqwipx, .table th.tinytable_css_srijzo29phbygeiqwipx { text-align: center; }
      .table td.tinytable_css_6yjs0eplx6e07zpy2xi7, .table th.tinytable_css_6yjs0eplx6e07zpy2xi7 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_db1nsd4npf74njlbdpl0, .table th.tinytable_css_db1nsd4npf74njlbdpl0 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_y8myxteircswz8f36x8b, .table th.tinytable_css_y8myxteircswz8f36x8b { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_z4cwybpe4i62j6nuup6e, .table th.tinytable_css_z4cwybpe4i62j6nuup6e { text-align: left; }
      .table td.tinytable_css_2zrmiift65d1dl3j6xzf, .table th.tinytable_css_2zrmiift65d1dl3j6xzf { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_1shnr6huwzqle0ev3ewr" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">25.495</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(12.287)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">disp</td>
                  <td data-row="3" data-col="1">-0.008</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.010)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">hp</td>
                  <td data-row="5" data-col="1">-0.038</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.017)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">qsec</td>
                  <td data-row="7" data-col="1">-0.035</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1">(0.624)</td>
                </tr>
<tr>
<td data-row="9" data-col="0">vs</td>
                  <td data-row="9" data-col="1">2.117</td>
                </tr>
<tr>
<td data-row="10" data-col="0"></td>
                  <td data-row="10" data-col="1">(2.024)</td>
                </tr>
<tr>
<td data-row="11" data-col="0">am</td>
                  <td data-row="11" data-col="1">4.374</td>
                </tr>
<tr>
<td data-row="12" data-col="0"></td>
                  <td data-row="12" data-col="1">(1.722)</td>
                </tr>
<tr>
<td data-row="13" data-col="0">Num.Obs.</td>
                  <td data-row="13" data-col="1">32</td>
                </tr>
<tr>
<td data-row="14" data-col="0">AIC</td>
                  <td data-row="14" data-col="1">165.5</td>
                </tr>
<tr>
<td data-row="15" data-col="0">BIC</td>
                  <td data-row="15" data-col="1">175.8</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>The second allowed type is a <code>data.frame</code> (or <code>tibble</code>). This data.frame/tibble <em>must</em> contain these 3 columns:</p>
<ol type="1">
<li>
<code>raw</code>: a string which <em>must</em> be one of the strings in <code>colnames(modelsummary::get_gof(model))</code>. Invalid values are silently ignored.</li>
<li>
<code>clean</code>: a string with the “clean” name of the statistic you want to appear in your final table.</li>
<li>
<code>fmt</code>: a string (<code><a href="https://modelsummary.com/man/fmt_sprintf.html">?fmt_sprintf</a></code>) or numeric value (<code><a href="https://modelsummary.com/man/fmt_decimal.html">?fmt_decimal</a></code>) used to format the statistics. You cannot pass a function here.</li>
</ol>
<p>If one of these 3 columns is missing in the dataframe, an error is thrown. If the dataframe contains these 3 columns and other columns, the other columns are silently ignored.</p>
<p>The goodness-of-fit statistics will be printed in the output table in the same order in which they appear in the <code>gof_map</code> data.frame.</p>
<p>You can see an example of a valid data frame by typing <code><a href="https://modelsummary.com/man/gof_map.html">modelsummary::gof_map</a></code>. This is the default data.frame that <code>modelsummary</code> uses to subset and reorder goodness-of-fit statistics. As you can see, <code>omit == TRUE</code> for quite a number of statistics. You can include them by setting <code>omit == FALSE</code>:</p>
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">gm</span> <span class="op">&lt;-</span> <span class="fu">modelsummary</span><span class="fu">::</span><span class="va"><a href="https://modelsummary.com/man/gof_map.html">gof_map</a></span></span>
<span><span class="va">gm</span><span class="op">$</span><span class="va">omit</span> <span class="op">&lt;-</span> <span class="cn">FALSE</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, gof_map <span class="op">=</span> <span class="va">gm</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>A convenient way to build a <code>gof_map</code> tibble is to use the <code>tribble</code> function from the <code>tibble</code> package. In this example, we insert special HTML code to display a superscript, so we use the <code>escape=FALSE</code> argument.</p>
<p>Warning: This <code>tribble</code> syntax may not work well when <code>fmt</code> is a function. In that case, please use the list syntax illustrated below.</p>
<div class="cell">
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">gm</span> <span class="op">&lt;-</span> <span class="fu">tibble</span><span class="fu">::</span><span class="fu"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span><span class="op">(</span></span>
<span>  <span class="op">~</span><span class="va">raw</span>,        <span class="op">~</span><span class="va">clean</span>,          <span class="op">~</span><span class="va">fmt</span>,</span>
<span>  <span class="st">"nobs"</span>,      <span class="st">"N"</span>,             <span class="fl">0</span>,</span>
<span>  <span class="st">"r.squared"</span>, <span class="st">"R&lt;sup&gt;2&lt;/sup&gt;"</span>, <span class="fl">2</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">models</span>,</span>
<span>  statistic <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  gof_map <span class="op">=</span> <span class="va">gm</span>,</span>
<span>  escape <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_jt0xjsn4sqgls0o09lfm(i, j, css_id) {
          var table = document.getElementById("tinytable_jt0xjsn4sqgls0o09lfm");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_jt0xjsn4sqgls0o09lfm(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_jt0xjsn4sqgls0o09lfm");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '6', j: 2 }, { i: '6', j: 1 }, { i: '6', j: 3 },  ], css_id: 'tinytable_css_cmdpqf1vccv51lr6txko',}, 
          { positions: [ { i: '4', j: 3 }, { i: '4', j: 1 }, { i: '4', j: 2 },  ], css_id: 'tinytable_css_f1eqloeiwtwluj6riycj',}, 
          { positions: [ { i: '1', j: 1 }, { i: '1', j: 2 }, { i: '5', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '5', j: 3 },  ], css_id: 'tinytable_css_3uz4bh5u1bfm43rrkfqk',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_brcs1o8kt85i8hrbjuzl',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_o0cxsnelhpbgqi4kbqph',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_w4ex7u3atb584sb2ak4y',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '5', j: 0 },  ], css_id: 'tinytable_css_mx8i292icex4a7mjjspm',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_omo2wm3npnonyitwqm54',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_jt0xjsn4sqgls0o09lfm(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_cmdpqf1vccv51lr6txko, .table th.tinytable_css_cmdpqf1vccv51lr6txko { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_f1eqloeiwtwluj6riycj, .table th.tinytable_css_f1eqloeiwtwluj6riycj { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_3uz4bh5u1bfm43rrkfqk, .table th.tinytable_css_3uz4bh5u1bfm43rrkfqk { text-align: center; }
      .table td.tinytable_css_brcs1o8kt85i8hrbjuzl, .table th.tinytable_css_brcs1o8kt85i8hrbjuzl { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_o0cxsnelhpbgqi4kbqph, .table th.tinytable_css_o0cxsnelhpbgqi4kbqph { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_w4ex7u3atb584sb2ak4y, .table th.tinytable_css_w4ex7u3atb584sb2ak4y { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_mx8i292icex4a7mjjspm, .table th.tinytable_css_mx8i292icex4a7mjjspm { text-align: left; }
      .table td.tinytable_css_omo2wm3npnonyitwqm54, .table th.tinytable_css_omo2wm3npnonyitwqm54 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_jt0xjsn4sqgls0o09lfm" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS 1</th>
                <th scope="col" data-row="0" data-col="2">Poisson</th>
                <th scope="col" data-row="0" data-col="3">OLS 2</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7948.667</td>
                  <td data-row="1" data-col="2">8.241</td>
                  <td data-row="1" data-col="3">16259.384</td>
                </tr>
<tr>
<td data-row="2" data-col="0">Literacy</td>
                  <td data-row="2" data-col="1">-39.121</td>
                  <td data-row="2" data-col="2">0.003</td>
                  <td data-row="2" data-col="3">3.680</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Clergy</td>
                  <td data-row="3" data-col="1">15.257</td>
                  <td data-row="3" data-col="2"></td>
                  <td data-row="3" data-col="3">77.148</td>
                </tr>
<tr>
<td data-row="4" data-col="0">Commerce</td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">0.011</td>
                  <td data-row="4" data-col="3"></td>
                </tr>
<tr>
<td data-row="5" data-col="0">N</td>
                  <td data-row="5" data-col="1">86</td>
                  <td data-row="5" data-col="2">86</td>
                  <td data-row="5" data-col="3">86</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R<sup>2</sup>
</td>
                  <td data-row="6" data-col="1">0.02</td>
                  <td data-row="6" data-col="2"></td>
                  <td data-row="6" data-col="3">0.07</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>The third allowed type is a <code>list</code>, which <em>may</em> be named. This list <em>must</em> have an element for each statistics we want to print. Each element <em>must</em> be a <em>named</em> list with exactly three elements:</p>
<ol type="1">
<li>
<code>raw</code>: a string with the name of a column produced by <code>get_gof(model)</code>.</li>
<li>
<code>clean</code>: a string with the “clean” name of the statistic you want to appear in your final table.</li>
<li>
<code>fmt</code>: a string (<code><a href="https://modelsummary.com/man/fmt_sprintf.html">?fmt_sprintf</a></code>), numeric value (<code><a href="https://modelsummary.com/man/fmt_decimal.html">?fmt_decimal</a></code>), or function which will be used to round/format the string in question.</li>
</ol>
<p>Here is an example:</p>
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">f</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="va">x</span>, <span class="fl">3</span><span class="op">)</span>, big.mark<span class="op">=</span><span class="st">","</span><span class="op">)</span></span>
<span><span class="va">gm</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"raw"</span> <span class="op">=</span> <span class="st">"nobs"</span>, <span class="st">"clean"</span> <span class="op">=</span> <span class="st">"N"</span>, <span class="st">"fmt"</span> <span class="op">=</span> <span class="va">f</span><span class="op">)</span>,</span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"raw"</span> <span class="op">=</span> <span class="st">"AIC"</span>, <span class="st">"clean"</span> <span class="op">=</span> <span class="st">"aic"</span>, <span class="st">"fmt"</span> <span class="op">=</span> <span class="va">f</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, gof_map <span class="op">=</span> <span class="va">gm</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>You can use a list built from the default <code><a href="https://modelsummary.com/man/gof_map.html">modelsummary::gof_map</a></code> as a starting point for your own list:</p>
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">gof_map</span> <span class="op">&lt;-</span> <span class="fu">modelsummary</span><span class="fu">::</span><span class="va"><a href="https://modelsummary.com/man/gof_map.html">gof_map</a></span> <span class="op">%&gt;%</span></span>
<span>  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="op">!</span><span class="va">omit</span><span class="op">)</span> <span class="op">%&gt;%</span></span>
<span>  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">omit</span><span class="op">)</span> <span class="op">%&gt;%</span></span>
<span>  <span class="fu">plyr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/plyr/man/dlply.html">dlply</a></span><span class="op">(</span><span class="fl">1</span>, <span class="va">c</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section><section id="gof_function" class="level1"><h1><code>gof_function</code></h1>
<p>The <code>gof_function</code> argument accepts a function which processes the model and returns a data frame with custom information about each model. For example, we can insert a row in the bottom portion of the table to display the dependent variable with:</p>
<div class="cell">
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">qsec</span> <span class="op">+</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">qsec</span> <span class="op">+</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="va">fun</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">model</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span><span class="st">"DV"</span> <span class="op">=</span> <span class="fu">insight</span><span class="fu">::</span><span class="fu"><a href="https://easystats.github.io/insight/reference/find_response.html">find_response</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, gof_function <span class="op">=</span> <span class="va">fun</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_rjinal3i5q6tt2gnhu8z(i, j, css_id) {
          var table = document.getElementById("tinytable_rjinal3i5q6tt2gnhu8z");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_rjinal3i5q6tt2gnhu8z(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_rjinal3i5q6tt2gnhu8z");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '15', j: 1 }, { i: '15', j: 2 },  ], css_id: 'tinytable_css_2ljs6kfaygfnnui39l5y',}, 
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 },  ], css_id: 'tinytable_css_s9s9e18jv588osxh9b81',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '3', j: 2 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '12', j: 2 }, { i: '3', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '7', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '14', j: 2 }, { i: '13', j: 2 },  ], css_id: 'tinytable_css_lmkmiyb8vgr65t2gad49',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_culwkirzqkaqas08at64',}, 
          { positions: [ { i: '15', j: 0 },  ], css_id: 'tinytable_css_l1op1wu8qilrb3xndmcw',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_kcbgtn9u1tpo2d15nglu',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_syh3dkigfp4ve48rk2xg',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_aeqa61if1gwte58xa5dy',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_rjinal3i5q6tt2gnhu8z(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_2ljs6kfaygfnnui39l5y, .table th.tinytable_css_2ljs6kfaygfnnui39l5y { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_s9s9e18jv588osxh9b81, .table th.tinytable_css_s9s9e18jv588osxh9b81 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_lmkmiyb8vgr65t2gad49, .table th.tinytable_css_lmkmiyb8vgr65t2gad49 { text-align: center; }
      .table td.tinytable_css_culwkirzqkaqas08at64, .table th.tinytable_css_culwkirzqkaqas08at64 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_l1op1wu8qilrb3xndmcw, .table th.tinytable_css_l1op1wu8qilrb3xndmcw { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_kcbgtn9u1tpo2d15nglu, .table th.tinytable_css_kcbgtn9u1tpo2d15nglu { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_syh3dkigfp4ve48rk2xg, .table th.tinytable_css_syh3dkigfp4ve48rk2xg { text-align: left; }
      .table td.tinytable_css_aeqa61if1gwte58xa5dy, .table th.tinytable_css_aeqa61if1gwte58xa5dy { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_rjinal3i5q6tt2gnhu8z" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">-27.840</td>
                  <td data-row="1" data-col="2">786.169</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(8.299)</td>
                  <td data-row="2" data-col="2">(87.415)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">qsec</td>
                  <td data-row="3" data-col="1">1.213</td>
                  <td data-row="3" data-col="2">-25.818</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.402)</td>
                  <td data-row="4" data-col="2">(4.230)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1">7.309</td>
                  <td data-row="5" data-col="2">-49.676</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(1.342)</td>
                  <td data-row="6" data-col="2">(14.138)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                  <td data-row="7" data-col="2">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.592</td>
                  <td data-row="8" data-col="2">0.650</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.564</td>
                  <td data-row="9" data-col="2">0.626</td>
                </tr>
<tr>
<td data-row="10" data-col="0">AIC</td>
                  <td data-row="10" data-col="1">184.1</td>
                  <td data-row="10" data-col="2">334.7</td>
                </tr>
<tr>
<td data-row="11" data-col="0">BIC</td>
                  <td data-row="11" data-col="1">189.9</td>
                  <td data-row="11" data-col="2">340.6</td>
                </tr>
<tr>
<td data-row="12" data-col="0">Log.Lik.</td>
                  <td data-row="12" data-col="1">-88.026</td>
                  <td data-row="12" data-col="2">-163.371</td>
                </tr>
<tr>
<td data-row="13" data-col="0">F</td>
                  <td data-row="13" data-col="1">21.056</td>
                  <td data-row="13" data-col="2">26.976</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">3.79</td>
                  <td data-row="14" data-col="2">39.90</td>
                </tr>
<tr>
<td data-row="15" data-col="0">DV</td>
                  <td data-row="15" data-col="1">mpg</td>
                  <td data-row="15" data-col="2">hp</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>In this example, we write a function factory to insert an indicator for whether a model includes control variables:</p>
<div class="cell">
<div class="sourceCode" id="cb50"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">wt</span> <span class="op">~</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">wt</span> <span class="op">~</span> <span class="va">qsec</span> <span class="op">+</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">mpg</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="va">check_controls</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">variables</span>, <span class="va">yes</span> <span class="op">=</span> <span class="st">"✓"</span>, <span class="va">no</span> <span class="op">=</span> <span class="st">""</span><span class="op">)</span> <span class="op">{</span></span>
<span>    <span class="fu">checkmate</span><span class="fu">::</span><span class="fu"><a href="https://mllg.github.io/checkmate/reference/checkCharacter.html">assert_character</a></span><span class="op">(</span><span class="va">variables</span>, min.len <span class="op">=</span> <span class="fl">1</span><span class="op">)</span></span>
<span>    <span class="fu">checkmate</span><span class="fu">::</span><span class="fu"><a href="https://mllg.github.io/checkmate/reference/checkString.html">assert_string</a></span><span class="op">(</span><span class="va">no</span><span class="op">)</span></span>
<span>    <span class="fu">checkmate</span><span class="fu">::</span><span class="fu"><a href="https://mllg.github.io/checkmate/reference/checkString.html">assert_string</a></span><span class="op">(</span><span class="va">yes</span><span class="op">)</span></span>
<span>    <span class="va">reg</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="st">"^"</span>, <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste</a></span><span class="op">(</span><span class="va">variables</span>, collapse <span class="op">=</span> <span class="st">"$|^"</span><span class="op">)</span>, <span class="st">"$"</span><span class="op">)</span></span>
<span>    <span class="va">fun</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">model</span><span class="op">)</span> <span class="op">{</span></span>
<span>        <span class="va">est</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://modelsummary.com/man/get_estimates.html">get_estimates</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span>
<span>        <span class="va">df</span> <span class="op">&lt;-</span> <span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/all.html">all</a></span><span class="op">(</span><span class="va">variables</span> <span class="op"><a href="https://rdrr.io/r/base/match.html">%in%</a></span> <span class="va">est</span><span class="op">$</span><span class="va">term</span><span class="op">)</span><span class="op">)</span> <span class="va">yes</span> <span class="kw">else</span> <span class="va">no</span></span>
<span>        <span class="va">df</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>Controls <span class="op">=</span> <span class="va">df</span><span class="op">)</span></span>
<span>        <span class="kw"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op">(</span><span class="va">df</span><span class="op">)</span></span>
<span>    <span class="op">}</span></span>
<span>    <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"fun"</span> <span class="op">=</span> <span class="va">fun</span>, <span class="st">"regex"</span> <span class="op">=</span> <span class="va">reg</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="va">cc</span> <span class="op">&lt;-</span> <span class="fu">check_controls</span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"hp"</span>, <span class="st">"mpg"</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, </span>
<span>    gof_function <span class="op">=</span> <span class="va">cc</span><span class="op">$</span><span class="va">fun</span>, </span>
<span>    coef_omit <span class="op">=</span> <span class="va">cc</span><span class="op">$</span><span class="va">regex</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_6oaqy6v1pomgjo89dg8d(i, j, css_id) {
          var table = document.getElementById("tinytable_6oaqy6v1pomgjo89dg8d");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_6oaqy6v1pomgjo89dg8d(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_6oaqy6v1pomgjo89dg8d");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '13', j: 1 }, { i: '13', j: 2 },  ], css_id: 'tinytable_css_a0edtvqcds2z0k62yzbk',}, 
          { positions: [ { i: '4', j: 2 }, { i: '4', j: 1 },  ], css_id: 'tinytable_css_b0gj4aycr4nkdsyw2826',}, 
          { positions: [ { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '12', j: 2 }, { i: '1', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '11', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 },  ], css_id: 'tinytable_css_l15ra0ph1xelwoz6bmva',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_a6hvd2e0tll5buqn4rq3',}, 
          { positions: [ { i: '13', j: 0 },  ], css_id: 'tinytable_css_dx6m6qf8q4ki8gehtgfq',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_ukb3x87q76kqj54b0w3p',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '12', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 },  ], css_id: 'tinytable_css_wus42qlncwutqpoug0vg',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_0sg42y7j5f9348bu01me',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_6oaqy6v1pomgjo89dg8d(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_a0edtvqcds2z0k62yzbk, .table th.tinytable_css_a0edtvqcds2z0k62yzbk { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_b0gj4aycr4nkdsyw2826, .table th.tinytable_css_b0gj4aycr4nkdsyw2826 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_l15ra0ph1xelwoz6bmva, .table th.tinytable_css_l15ra0ph1xelwoz6bmva { text-align: center; }
      .table td.tinytable_css_a6hvd2e0tll5buqn4rq3, .table th.tinytable_css_a6hvd2e0tll5buqn4rq3 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_dx6m6qf8q4ki8gehtgfq, .table th.tinytable_css_dx6m6qf8q4ki8gehtgfq { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ukb3x87q76kqj54b0w3p, .table th.tinytable_css_ukb3x87q76kqj54b0w3p { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_wus42qlncwutqpoug0vg, .table th.tinytable_css_wus42qlncwutqpoug0vg { text-align: left; }
      .table td.tinytable_css_0sg42y7j5f9348bu01me, .table th.tinytable_css_0sg42y7j5f9348bu01me { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_6oaqy6v1pomgjo89dg8d" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">4.925</td>
                  <td data-row="1" data-col="2">1.290</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(1.765)</td>
                  <td data-row="2" data-col="2">(1.660)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">qsec</td>
                  <td data-row="3" data-col="1">-0.096</td>
                  <td data-row="3" data-col="2">0.210</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.098)</td>
                  <td data-row="4" data-col="2">(0.065)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                  <td data-row="5" data-col="2">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2</td>
                  <td data-row="6" data-col="1">0.031</td>
                  <td data-row="6" data-col="2">0.820</td>
                </tr>
<tr>
<td data-row="7" data-col="0">R2 Adj.</td>
                  <td data-row="7" data-col="1">-0.002</td>
                  <td data-row="7" data-col="2">0.801</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">93.4</td>
                  <td data-row="8" data-col="2">43.5</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">97.8</td>
                  <td data-row="9" data-col="2">50.8</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-43.705</td>
                  <td data-row="10" data-col="2">-16.749</td>
                </tr>
<tr>
<td data-row="11" data-col="0">F</td>
                  <td data-row="11" data-col="1">0.945</td>
                  <td data-row="11" data-col="2">42.570</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1">0.95</td>
                  <td data-row="12" data-col="2">0.41</td>
                </tr>
<tr>
<td data-row="13" data-col="0">Controls</td>
                  <td data-row="13" data-col="1"></td>
                  <td data-row="13" data-col="2">✓</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Notice that <code>gof_map</code> is processed <strong>after</strong> <code>gof_function</code>. So, if you use <code>gof_function</code> in conjuction with <code>gof_map</code>, make sure your additional statistics appear also in <code>gof_map</code>.</p>
</section><section id="shape" class="level1"><h1><code>shape</code></h1>
<p>This section requires version 1.3.1 of <code>modelsummary</code>. If this version is not available on CRAN yet, you can install the development version by following <a href="https://modelsummary.com/#installation">the instructions on the website.</a></p>
<p>The <code>shape</code> argument accepts:</p>
<ol type="1">
<li>A formula which determines the structure of the table, and can display “grouped” coefficients together (e.g., multivariate outcome or mixed-effects models).</li>
<li>The strings “cbind”, “rbind” or “rcollapse” to stack multiple tables on top of each other and present models in distinct “panels”.</li>
</ol>
<section id="formula" class="level2"><h2 class="anchored" data-anchor-id="formula">Formula</h2>
<p>The left side of the formula represents the rows and the right side represents the columns. The default formula is <code>term + statistic ~ model</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">m</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">drat</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">m</span>, shape <span class="op">=</span> <span class="va">term</span> <span class="op">+</span> <span class="va">statistic</span> <span class="op">~</span> <span class="va">model</span>, gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_tbrsoodc9faa0kjo9kzl(i, j, css_id) {
          var table = document.getElementById("tinytable_tbrsoodc9faa0kjo9kzl");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_tbrsoodc9faa0kjo9kzl(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_tbrsoodc9faa0kjo9kzl");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 },  ], css_id: 'tinytable_css_x5bstirazups9chrlnw4',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '3', j: 2 }, { i: '3', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 },  ], css_id: 'tinytable_css_xpnw7ta4lc01z2a61c7o',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_o56bsetco6ybz7lvuirc',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_qsc4llp52dnx2bpc7zkj',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 },  ], css_id: 'tinytable_css_eix0q5e6551l8gheigb7',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_pn2yvmr22ao3drp7713s',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_tbrsoodc9faa0kjo9kzl(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_x5bstirazups9chrlnw4, .table th.tinytable_css_x5bstirazups9chrlnw4 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_xpnw7ta4lc01z2a61c7o, .table th.tinytable_css_xpnw7ta4lc01z2a61c7o { text-align: center; }
      .table td.tinytable_css_o56bsetco6ybz7lvuirc, .table th.tinytable_css_o56bsetco6ybz7lvuirc { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_qsc4llp52dnx2bpc7zkj, .table th.tinytable_css_qsc4llp52dnx2bpc7zkj { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_eix0q5e6551l8gheigb7, .table th.tinytable_css_eix0q5e6551l8gheigb7 { text-align: left; }
      .table td.tinytable_css_pn2yvmr22ao3drp7713s, .table th.tinytable_css_pn2yvmr22ao3drp7713s { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_tbrsoodc9faa0kjo9kzl" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">30.099</td>
                  <td data-row="1" data-col="2">10.790</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(1.634)</td>
                  <td data-row="2" data-col="2">(5.078)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">-0.068</td>
                  <td data-row="3" data-col="2">-0.052</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.010)</td>
                  <td data-row="4" data-col="2">(0.009)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1"></td>
                  <td data-row="5" data-col="2">4.698</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1"></td>
                  <td data-row="6" data-col="2">(1.192)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>We can display statistics horizontally with:</p>
<div class="cell">
<div class="sourceCode" id="cb52"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">m</span>,</span>
<span>             shape <span class="op">=</span> <span class="va">term</span> <span class="op">~</span> <span class="va">model</span> <span class="op">+</span> <span class="va">statistic</span>,</span>
<span>             statistic <span class="op">=</span> <span class="st">"conf.int"</span>,</span>
<span>             gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_d9oe2jml3xui84x7e0me(i, j, css_id) {
          var table = document.getElementById("tinytable_d9oe2jml3xui84x7e0me");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_d9oe2jml3xui84x7e0me(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_d9oe2jml3xui84x7e0me");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '-1', j: 6 }, { i: '-1', j: 3 }, { i: '-1', j: 4 }, { i: '-1', j: 5 },  ], css_id: 'tinytable_css_elxcyuc83h6qtks7vitq',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '3', j: 3 }, { i: '3', j: 4 }, { i: '3', j: 5 }, { i: '3', j: 6 },  ], css_id: 'tinytable_css_r48x2wshjfakzq9u9zmw',}, 
          { positions: [ { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '1', j: 1 }, { i: '1', j: 2 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '2', j: 4 }, { i: '2', j: 5 }, { i: '2', j: 6 }, { i: '1', j: 4 }, { i: '1', j: 5 }, { i: '1', j: 6 },  ], css_id: 'tinytable_css_lskz377r9t2cflnrxd8c',}, 
          { positions: [ { i: '-1', j: 2 }, { i: '-1', j: 1 },  ], css_id: 'tinytable_css_d84l3wseoo2ueydri65l',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 }, { i: '0', j: 6 },  ], css_id: 'tinytable_css_l85vctkrtbf5y5ik1vvd',}, 
          { positions: [ { i: '3', j: 0 },  ], css_id: 'tinytable_css_wcq5yk08vqfhvg2pjrf9',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 },  ], css_id: 'tinytable_css_ox3oocpz9uhw2ypf3b85',}, 
          { positions: [ { i: '-1', j: 0 },  ], css_id: 'tinytable_css_jw57xrzula0heytz1c3m',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_4wbuurw516t9447abcpw',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_d9oe2jml3xui84x7e0me(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_elxcyuc83h6qtks7vitq, .table th.tinytable_css_elxcyuc83h6qtks7vitq { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_r48x2wshjfakzq9u9zmw, .table th.tinytable_css_r48x2wshjfakzq9u9zmw { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_lskz377r9t2cflnrxd8c, .table th.tinytable_css_lskz377r9t2cflnrxd8c { text-align: center; }
      .table td.tinytable_css_d84l3wseoo2ueydri65l, .table th.tinytable_css_d84l3wseoo2ueydri65l { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_l85vctkrtbf5y5ik1vvd, .table th.tinytable_css_l85vctkrtbf5y5ik1vvd { text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_wcq5yk08vqfhvg2pjrf9, .table th.tinytable_css_wcq5yk08vqfhvg2pjrf9 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ox3oocpz9uhw2ypf3b85, .table th.tinytable_css_ox3oocpz9uhw2ypf3b85 { text-align: left; }
      .table td.tinytable_css_jw57xrzula0heytz1c3m, .table th.tinytable_css_jw57xrzula0heytz1c3m { text-align: left; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_4wbuurw516t9447abcpw, .table th.tinytable_css_4wbuurw516t9447abcpw { text-align: left; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_d9oe2jml3xui84x7e0me" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead>
<tr>
<th scope="col" align="center" colspan="1" data-row="-1" data-col="0"> </th>
<th scope="col" align="center" colspan="3" data-row="-1" data-col="1">(1)</th>
<th scope="col" align="center" colspan="3" data-row="-1" data-col="2">(2)</th>
</tr>
<tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">Est.</th>
                <th scope="col" data-row="0" data-col="2">2.5 %</th>
                <th scope="col" data-row="0" data-col="3">97.5 %</th>
                <th scope="col" data-row="0" data-col="4">Est.</th>
                <th scope="col" data-row="0" data-col="5">2.5 %</th>
                <th scope="col" data-row="0" data-col="6">97.5 %</th>
              </tr>
</thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">30.099</td>
                  <td data-row="1" data-col="2">26.762</td>
                  <td data-row="1" data-col="3">33.436</td>
                  <td data-row="1" data-col="4">10.790</td>
                  <td data-row="1" data-col="5">0.405</td>
                  <td data-row="1" data-col="6">21.175</td>
                </tr>
<tr>
<td data-row="2" data-col="0">hp</td>
                  <td data-row="2" data-col="1">-0.068</td>
                  <td data-row="2" data-col="2">-0.089</td>
                  <td data-row="2" data-col="3">-0.048</td>
                  <td data-row="2" data-col="4">-0.052</td>
                  <td data-row="2" data-col="5">-0.071</td>
                  <td data-row="2" data-col="6">-0.033</td>
                </tr>
<tr>
<td data-row="3" data-col="0">drat</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2"></td>
                  <td data-row="3" data-col="3"></td>
                  <td data-row="3" data-col="4">4.698</td>
                  <td data-row="3" data-col="5">2.261</td>
                  <td data-row="3" data-col="6">7.135</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>The order of terms in the formula determines the order of headers in the table.</p>
<div class="cell">
<div class="sourceCode" id="cb53"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">m</span>,</span>
<span>             shape <span class="op">=</span> <span class="va">term</span> <span class="op">~</span> <span class="va">statistic</span> <span class="op">+</span> <span class="va">model</span>,</span>
<span>             statistic <span class="op">=</span> <span class="st">"conf.int"</span>,</span>
<span>             gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_p6lg7fhhmyl9z2hzu5zs(i, j, css_id) {
          var table = document.getElementById("tinytable_p6lg7fhhmyl9z2hzu5zs");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_p6lg7fhhmyl9z2hzu5zs(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_p6lg7fhhmyl9z2hzu5zs");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '-1', j: 6 }, { i: '-1', j: 4 }, { i: '-1', j: 5 },  ], css_id: 'tinytable_css_kzshiih9t2swyl69ozpq',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '3', j: 3 }, { i: '3', j: 5 }, { i: '3', j: 6 }, { i: '3', j: 4 },  ], css_id: 'tinytable_css_vozyz2x3qnmtdl32e6hz',}, 
          { positions: [ { i: '2', j: 2 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '2', j: 4 }, { i: '1', j: 2 }, { i: '2', j: 6 }, { i: '1', j: 4 }, { i: '1', j: 5 }, { i: '2', j: 5 }, { i: '1', j: 6 },  ], css_id: 'tinytable_css_gz3f5s4pgch9wqmcjw8b',}, 
          { positions: [ { i: '-1', j: 2 }, { i: '-1', j: 3 }, { i: '-1', j: 1 },  ], css_id: 'tinytable_css_0upzp4lmugyieh28f7ro',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 }, { i: '0', j: 5 }, { i: '0', j: 6 },  ], css_id: 'tinytable_css_h2y9careyjnrlry42w88',}, 
          { positions: [ { i: '3', j: 0 },  ], css_id: 'tinytable_css_ocjx1p6r4vvwqoxk58bg',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 },  ], css_id: 'tinytable_css_7rhfclj76771v1bw5eht',}, 
          { positions: [ { i: '-1', j: 0 },  ], css_id: 'tinytable_css_2t798ebc63hkwad3id9v',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_idy7s6vup1s8mptlokxh',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_p6lg7fhhmyl9z2hzu5zs(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_kzshiih9t2swyl69ozpq, .table th.tinytable_css_kzshiih9t2swyl69ozpq { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_vozyz2x3qnmtdl32e6hz, .table th.tinytable_css_vozyz2x3qnmtdl32e6hz { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_gz3f5s4pgch9wqmcjw8b, .table th.tinytable_css_gz3f5s4pgch9wqmcjw8b { text-align: center; }
      .table td.tinytable_css_0upzp4lmugyieh28f7ro, .table th.tinytable_css_0upzp4lmugyieh28f7ro { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_h2y9careyjnrlry42w88, .table th.tinytable_css_h2y9careyjnrlry42w88 { text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_ocjx1p6r4vvwqoxk58bg, .table th.tinytable_css_ocjx1p6r4vvwqoxk58bg { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_7rhfclj76771v1bw5eht, .table th.tinytable_css_7rhfclj76771v1bw5eht { text-align: left; }
      .table td.tinytable_css_2t798ebc63hkwad3id9v, .table th.tinytable_css_2t798ebc63hkwad3id9v { text-align: left; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_idy7s6vup1s8mptlokxh, .table th.tinytable_css_idy7s6vup1s8mptlokxh { text-align: left; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_p6lg7fhhmyl9z2hzu5zs" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead>
<tr>
<th scope="col" align="center" colspan="1" data-row="-1" data-col="0"> </th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="1">Est.</th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="2">2.5 %</th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="3">97.5 %</th>
</tr>
<tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
                <th scope="col" data-row="0" data-col="3">(1)</th>
                <th scope="col" data-row="0" data-col="4">(2)</th>
                <th scope="col" data-row="0" data-col="5">(1)</th>
                <th scope="col" data-row="0" data-col="6">(2)</th>
              </tr>
</thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">30.099</td>
                  <td data-row="1" data-col="2">10.790</td>
                  <td data-row="1" data-col="3">26.762</td>
                  <td data-row="1" data-col="4">0.405</td>
                  <td data-row="1" data-col="5">33.436</td>
                  <td data-row="1" data-col="6">21.175</td>
                </tr>
<tr>
<td data-row="2" data-col="0">hp</td>
                  <td data-row="2" data-col="1">-0.068</td>
                  <td data-row="2" data-col="2">-0.052</td>
                  <td data-row="2" data-col="3">-0.089</td>
                  <td data-row="2" data-col="4">-0.071</td>
                  <td data-row="2" data-col="5">-0.048</td>
                  <td data-row="2" data-col="6">-0.033</td>
                </tr>
<tr>
<td data-row="3" data-col="0">drat</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2">4.698</td>
                  <td data-row="3" data-col="3"></td>
                  <td data-row="3" data-col="4">2.261</td>
                  <td data-row="3" data-col="5"></td>
                  <td data-row="3" data-col="6">7.135</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p><code>shape</code> does partial matching and will try to fill-in incomplete formulas:</p>
<div class="cell">
<div class="sourceCode" id="cb54"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">m</span>, shape <span class="op">=</span> <span class="op">~</span> <span class="va">statistic</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Some models like multinomial logit or GAMLSS produce “grouped” parameter estimates. To display these groups, we can include a group identifier in the <code>shape</code> formula. This group identifier must be one of the column names produced by <code>get_estimates(model)</code>. For example, in models produced by <code><a href="https://rdrr.io/pkg/nnet/man/multinom.html">nnet::multinom</a></code>, the group identifier is called “response”:</p>
<div class="cell">
<div class="sourceCode" id="cb55"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="http://www.stats.ox.ac.uk/pub/MASS4/">nnet</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">dat_multinom</span> <span class="op">&lt;-</span> <span class="va">mtcars</span></span>
<span><span class="va">dat_multinom</span><span class="op">$</span><span class="va">cyl</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/sprintf.html">sprintf</a></span><span class="op">(</span><span class="st">"Cyl: %s"</span>, <span class="va">dat_multinom</span><span class="op">$</span><span class="va">cyl</span><span class="op">)</span></span>
<span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="fu">nnet</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/nnet/man/multinom.html">multinom</a></span><span class="op">(</span><span class="va">cyl</span> <span class="op">~</span> <span class="va">mpg</span>, data <span class="op">=</span> <span class="va">dat_multinom</span>, trace <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>,</span>
<span>    <span class="fu">nnet</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/nnet/man/multinom.html">multinom</a></span><span class="op">(</span><span class="va">cyl</span> <span class="op">~</span> <span class="va">mpg</span> <span class="op">+</span> <span class="va">drat</span>, data <span class="op">=</span> <span class="va">dat_multinom</span>, trace <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/get_estimates.html">get_estimates</a></span><span class="op">(</span><span class="va">mod</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>         term  estimate std.error conf.level    conf.low   conf.high statistic df.error    p.value response s.value group
1 (Intercept) 47.252432 34.975171       0.95 -21.2976435 115.8025065  1.351028      Inf 0.17668650   Cyl: 6     2.5      
2         mpg -2.205418  1.637963       0.95  -5.4157653   1.0049299 -1.346440      Inf 0.17816078   Cyl: 6     2.5      
3 (Intercept) 72.440246 37.175162       0.95  -0.4217332 145.3022247  1.948619      Inf 0.05134088   Cyl: 8     4.3      
4         mpg -3.579991  1.774693       0.95  -7.0583242  -0.1016573 -2.017246      Inf 0.04366989   Cyl: 8     4.5      </code></pre>
</div>
</div>
<p>To summarize the results, we can type:</p>
<div class="cell">
<div class="sourceCode" id="cb57"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># modelsummary(mod, shape = term + response ~ statistic)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>The terms of the <code>shape</code> formula above can of course be rearranged to reshape the table. For example:</p>
<div class="cell">
<div class="sourceCode" id="cb58"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, shape <span class="op">=</span> <span class="va">model</span> <span class="op">+</span> <span class="va">term</span> <span class="op">~</span> <span class="va">response</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_3tkvq1y3uoma7h7pqzor(i, j, css_id) {
          var table = document.getElementById("tinytable_3tkvq1y3uoma7h7pqzor");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_3tkvq1y3uoma7h7pqzor(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_3tkvq1y3uoma7h7pqzor");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 2 }, { i: '10', j: 3 },  ], css_id: 'tinytable_css_mtv4thzf6a5qc0ou8koh',}, 
          { positions: [ { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '3', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '3', j: 3 }, { i: '7', j: 2 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '7', j: 3 }, { i: '4', j: 3 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '8', j: 3 }, { i: '9', j: 3 },  ], css_id: 'tinytable_css_gbw7q9vng0lo8d5xol7t',}, 
          { positions: [ { i: '0', j: 2 }, { i: '0', j: 3 },  ], css_id: 'tinytable_css_jwydugj346ph8k3r21b9',}, 
          { positions: [ { i: '10', j: 0 }, { i: '10', j: 1 },  ], css_id: 'tinytable_css_iv6djg8mw5gfjhhbyn8a',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '3', j: 1 }, { i: '7', j: 0 }, { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '7', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 },  ], css_id: 'tinytable_css_xtvic0qs2safg99qt5b9',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 },  ], css_id: 'tinytable_css_ui4os1jnpfghtz4lo502',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_3tkvq1y3uoma7h7pqzor(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_mtv4thzf6a5qc0ou8koh, .table th.tinytable_css_mtv4thzf6a5qc0ou8koh { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_gbw7q9vng0lo8d5xol7t, .table th.tinytable_css_gbw7q9vng0lo8d5xol7t { text-align: center; }
      .table td.tinytable_css_jwydugj346ph8k3r21b9, .table th.tinytable_css_jwydugj346ph8k3r21b9 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_iv6djg8mw5gfjhhbyn8a, .table th.tinytable_css_iv6djg8mw5gfjhhbyn8a { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_xtvic0qs2safg99qt5b9, .table th.tinytable_css_xtvic0qs2safg99qt5b9 { text-align: left; }
      .table td.tinytable_css_ui4os1jnpfghtz4lo502, .table th.tinytable_css_ui4os1jnpfghtz4lo502 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_3tkvq1y3uoma7h7pqzor" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">  </th>
                <th scope="col" data-row="0" data-col="2">Cyl: 6</th>
                <th scope="col" data-row="0" data-col="3">Cyl: 8</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(1)</td>
                  <td data-row="1" data-col="1">(Intercept)</td>
                  <td data-row="1" data-col="2">47.252</td>
                  <td data-row="1" data-col="3">72.440</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1"></td>
                  <td data-row="2" data-col="2">(34.975)</td>
                  <td data-row="2" data-col="3">(37.175)</td>
                </tr>
<tr>
<td data-row="3" data-col="0"></td>
                  <td data-row="3" data-col="1">mpg</td>
                  <td data-row="3" data-col="2">-2.205</td>
                  <td data-row="3" data-col="3">-3.580</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">(1.638)</td>
                  <td data-row="4" data-col="3">(1.775)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">(2)</td>
                  <td data-row="5" data-col="1">(Intercept)</td>
                  <td data-row="5" data-col="2">89.573</td>
                  <td data-row="5" data-col="3">117.971</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1"></td>
                  <td data-row="6" data-col="2">(86.884)</td>
                  <td data-row="6" data-col="3">(87.998)</td>
                </tr>
<tr>
<td data-row="7" data-col="0"></td>
                  <td data-row="7" data-col="1">mpg</td>
                  <td data-row="7" data-col="2">-3.627</td>
                  <td data-row="7" data-col="3">-4.838</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">(3.869)</td>
                  <td data-row="8" data-col="3">(3.915)</td>
                </tr>
<tr>
<td data-row="9" data-col="0"></td>
                  <td data-row="9" data-col="1">drat</td>
                  <td data-row="9" data-col="2">-3.210</td>
                  <td data-row="9" data-col="3">-5.028</td>
                </tr>
<tr>
<td data-row="10" data-col="0"></td>
                  <td data-row="10" data-col="1"></td>
                  <td data-row="10" data-col="2">(3.810)</td>
                  <td data-row="10" data-col="3">(4.199)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>We can combine the <code>term</code> and group identifier columns by inserting an interaction colon <code>:</code> instead of the <code>+</code> in the formula:</p>
<div class="cell">
<div class="sourceCode" id="cb59"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://marginaleffects.com/">marginaleffects</a></span><span class="op">)</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/glm.html">glm</a></span><span class="op">(</span><span class="va">am</span> <span class="op">~</span> <span class="va">mpg</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span>, family <span class="op">=</span> <span class="va">binomial</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="va">mfx</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://marginaleffects.com/man/r/slopes.html">avg_slopes</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mfx</span>, shape <span class="op">=</span> <span class="va">term</span> <span class="op">+</span> <span class="va">contrast</span> <span class="op">~</span> <span class="va">model</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_sgdlmaxset8zlvr7jaux(i, j, css_id) {
          var table = document.getElementById("tinytable_sgdlmaxset8zlvr7jaux");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_sgdlmaxset8zlvr7jaux(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_sgdlmaxset8zlvr7jaux");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '12', j: 2 },  ], css_id: 'tinytable_css_xm37l39oz6vx8z0dwilb',}, 
          { positions: [ { i: '6', j: 2 },  ], css_id: 'tinytable_css_2bz1fdmia0sitt5vzgmh',}, 
          { positions: [ { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '10', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '11', j: 2 },  ], css_id: 'tinytable_css_igid0rrdpfbwno6rmmpd',}, 
          { positions: [ { i: '0', j: 2 },  ], css_id: 'tinytable_css_gxcc61xeeuwl7mdkkqaa',}, 
          { positions: [ { i: '12', j: 0 }, { i: '12', j: 1 },  ], css_id: 'tinytable_css_e2tayouj7ru9x66nqdy4',}, 
          { positions: [ { i: '6', j: 0 }, { i: '6', j: 1 },  ], css_id: 'tinytable_css_soowdzzxy8839ccvhzih',}, 
          { positions: [ { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '1', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '1', j: 1 }, { i: '11', j: 0 }, { i: '3', j: 1 }, { i: '9', j: 0 }, { i: '5', j: 1 }, { i: '2', j: 1 }, { i: '7', j: 1 }, { i: '4', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '8', j: 1 },  ], css_id: 'tinytable_css_dqr33zchu8ohtpgsno8u',}, 
          { positions: [ { i: '0', j: 0 }, { i: '0', j: 1 },  ], css_id: 'tinytable_css_5lubwewhh3wsse523o13',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_sgdlmaxset8zlvr7jaux(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_xm37l39oz6vx8z0dwilb, .table th.tinytable_css_xm37l39oz6vx8z0dwilb { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_2bz1fdmia0sitt5vzgmh, .table th.tinytable_css_2bz1fdmia0sitt5vzgmh { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_igid0rrdpfbwno6rmmpd, .table th.tinytable_css_igid0rrdpfbwno6rmmpd { text-align: center; }
      .table td.tinytable_css_gxcc61xeeuwl7mdkkqaa, .table th.tinytable_css_gxcc61xeeuwl7mdkkqaa { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_e2tayouj7ru9x66nqdy4, .table th.tinytable_css_e2tayouj7ru9x66nqdy4 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_soowdzzxy8839ccvhzih, .table th.tinytable_css_soowdzzxy8839ccvhzih { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_dqr33zchu8ohtpgsno8u, .table th.tinytable_css_dqr33zchu8ohtpgsno8u { text-align: left; }
      .table td.tinytable_css_5lubwewhh3wsse523o13, .table th.tinytable_css_5lubwewhh3wsse523o13 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_sgdlmaxset8zlvr7jaux" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">  </th>
                <th scope="col" data-row="0" data-col="2">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">cyl</td>
                  <td data-row="1" data-col="1">6 - 4</td>
                  <td data-row="1" data-col="2">0.097</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1"></td>
                  <td data-row="2" data-col="2">(0.166)</td>
                </tr>
<tr>
<td data-row="3" data-col="0"></td>
                  <td data-row="3" data-col="1">8 - 4</td>
                  <td data-row="3" data-col="2">0.093</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">(0.234)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">mpg</td>
                  <td data-row="5" data-col="1">dY/dX</td>
                  <td data-row="5" data-col="2">0.056</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1"></td>
                  <td data-row="6" data-col="2">(0.027)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1"></td>
                  <td data-row="7" data-col="2">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">37.4</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1"></td>
                  <td data-row="9" data-col="2">43.3</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1"></td>
                  <td data-row="10" data-col="2">-14.702</td>
                </tr>
<tr>
<td data-row="11" data-col="0">F</td>
                  <td data-row="11" data-col="1"></td>
                  <td data-row="11" data-col="2">2.236</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1"></td>
                  <td data-row="12" data-col="2">0.39</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<div class="cell">
<div class="sourceCode" id="cb60"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mfx</span>, shape <span class="op">=</span> <span class="va">term</span> <span class="op">:</span> <span class="va">contrast</span> <span class="op">~</span> <span class="va">model</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_5vkyvh1xtgf3l1p4grwd(i, j, css_id) {
          var table = document.getElementById("tinytable_5vkyvh1xtgf3l1p4grwd");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_5vkyvh1xtgf3l1p4grwd(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_5vkyvh1xtgf3l1p4grwd");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '12', j: 1 },  ], css_id: 'tinytable_css_8o65t3uc3kqi2i7mt81l',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_owlkh7qp9z6w0jzwnrxv',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '11', j: 1 },  ], css_id: 'tinytable_css_c1un8o0uuw2fjgwkxs6f',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_rwvtu1rpaf8i1t4fbk2m',}, 
          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_vc36liz3qe848ce1s5mt',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_zxrrutk5mt5q9vbl4ym7',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 },  ], css_id: 'tinytable_css_01r2bgg7ki5rc7kwfiry',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_kkpjmns83t73a9ne7645',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_5vkyvh1xtgf3l1p4grwd(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_8o65t3uc3kqi2i7mt81l, .table th.tinytable_css_8o65t3uc3kqi2i7mt81l { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_owlkh7qp9z6w0jzwnrxv, .table th.tinytable_css_owlkh7qp9z6w0jzwnrxv { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_c1un8o0uuw2fjgwkxs6f, .table th.tinytable_css_c1un8o0uuw2fjgwkxs6f { text-align: center; }
      .table td.tinytable_css_rwvtu1rpaf8i1t4fbk2m, .table th.tinytable_css_rwvtu1rpaf8i1t4fbk2m { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_vc36liz3qe848ce1s5mt, .table th.tinytable_css_vc36liz3qe848ce1s5mt { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_zxrrutk5mt5q9vbl4ym7, .table th.tinytable_css_zxrrutk5mt5q9vbl4ym7 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_01r2bgg7ki5rc7kwfiry, .table th.tinytable_css_01r2bgg7ki5rc7kwfiry { text-align: left; }
      .table td.tinytable_css_kkpjmns83t73a9ne7645, .table th.tinytable_css_kkpjmns83t73a9ne7645 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_5vkyvh1xtgf3l1p4grwd" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">cyl 6 - 4</td>
                  <td data-row="1" data-col="1">0.097</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.166)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">cyl 8 - 4</td>
                  <td data-row="3" data-col="1">0.093</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.234)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">mpg dY/dX</td>
                  <td data-row="5" data-col="1">0.056</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.027)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">37.4</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">43.3</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-14.702</td>
                </tr>
<tr>
<td data-row="11" data-col="0">F</td>
                  <td data-row="11" data-col="1">2.236</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1">0.39</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="string-rbind-or-rcollapse-panels-of-models-in-stacked-regression-tables" class="level2"><h2 class="anchored" data-anchor-id="string-rbind-or-rcollapse-panels-of-models-in-stacked-regression-tables">String (“rbind” or “rcollapse”): Panels of models in stacked regression tables</h2>
<p>Note: The code in this section requires version 1.3.0 or the development version of <code>modelsummary</code>. See <a href="https://modelsummary.com/index.html">the website</a> for installation instructions.</p>
<p>This section shows how to “stack/bind” multiple regression tables on top of one another, to display the results several models side-by-side and top-to-bottom. For example, imagine that we want to present 4 different models, half of which are estimated using a different outcome variable. When using <code>modelsummary</code>, we store models in a list. When using <code>modelsummary</code> with <code>shape="rbind"</code> or <code>shape="rbind"</code>, we store models in a list of lists:</p>
<div class="cell">
<div class="sourceCode" id="cb61"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">gm</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"r.squared"</span>, <span class="st">"nobs"</span>, <span class="st">"rmse"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">panels</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="fl">1</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span>  <span class="op">)</span>,</span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="fl">1</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span>  <span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">panels</span>,</span>
<span>  shape <span class="op">=</span> <span class="st">"rbind"</span>,</span>
<span>  gof_map <span class="op">=</span> <span class="va">gm</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_nlrvuiej2pao3bpl5pv8(i, j, css_id) {
          var table = document.getElementById("tinytable_nlrvuiej2pao3bpl5pv8");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_nlrvuiej2pao3bpl5pv8(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_nlrvuiej2pao3bpl5pv8");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '14', j: 1 }, { i: '14', j: 2 },  ], css_id: 'tinytable_css_fdwb5qqou4qwx58r6orh',}, 
          { positions: [ { i: '1', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '12', j: 2 }, { i: '2', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '13', j: 2 },  ], css_id: 'tinytable_css_co7j8hr1xl3a9ffqpuh1',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_dyd1sqbw5z8qyq1idiic',}, 
          { positions: [ { i: '14', j: 0 },  ], css_id: 'tinytable_css_82fe8tr83auqvui0njgk',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_n4udd3q9xes8beq9fw1q',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_t2gbmqf4ilh55i7mf594',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_nlrvuiej2pao3bpl5pv8(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_fdwb5qqou4qwx58r6orh, .table th.tinytable_css_fdwb5qqou4qwx58r6orh { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_co7j8hr1xl3a9ffqpuh1, .table th.tinytable_css_co7j8hr1xl3a9ffqpuh1 { text-align: center; }
      .table td.tinytable_css_dyd1sqbw5z8qyq1idiic, .table th.tinytable_css_dyd1sqbw5z8qyq1idiic { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_82fe8tr83auqvui0njgk, .table th.tinytable_css_82fe8tr83auqvui0njgk { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_n4udd3q9xes8beq9fw1q, .table th.tinytable_css_n4udd3q9xes8beq9fw1q { text-align: left; }
      .table td.tinytable_css_t2gbmqf4ilh55i7mf594, .table th.tinytable_css_t2gbmqf4ilh55i7mf594 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_nlrvuiej2pao3bpl5pv8" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">20.091</td>
                  <td data-row="1" data-col="2">-5.114</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(1.065)</td>
                  <td data-row="2" data-col="2">(10.030)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">qsec</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2">1.412</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">(0.559)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">R2</td>
                  <td data-row="5" data-col="1">0.000</td>
                  <td data-row="5" data-col="2">0.175</td>
                </tr>
<tr>
<td data-row="6" data-col="0">Num.Obs.</td>
                  <td data-row="6" data-col="1">32</td>
                  <td data-row="6" data-col="2">32</td>
                </tr>
<tr>
<td data-row="7" data-col="0">RMSE</td>
                  <td data-row="7" data-col="1">5.93</td>
                  <td data-row="7" data-col="2">5.39</td>
                </tr>
<tr>
<td data-row="8" data-col="0">(Intercept)</td>
                  <td data-row="8" data-col="1">146.688</td>
                  <td data-row="8" data-col="2">631.704</td>
                </tr>
<tr>
<td data-row="9" data-col="0"></td>
                  <td data-row="9" data-col="1">(12.120)</td>
                  <td data-row="9" data-col="2">(88.700)</td>
                </tr>
<tr>
<td data-row="10" data-col="0">qsec</td>
                  <td data-row="10" data-col="1"></td>
                  <td data-row="10" data-col="2">-27.174</td>
                </tr>
<tr>
<td data-row="11" data-col="0"></td>
                  <td data-row="11" data-col="1"></td>
                  <td data-row="11" data-col="2">(4.946)</td>
                </tr>
<tr>
<td data-row="12" data-col="0">R2</td>
                  <td data-row="12" data-col="1">0.000</td>
                  <td data-row="12" data-col="2">0.502</td>
                </tr>
<tr>
<td data-row="13" data-col="0">Num.Obs.</td>
                  <td data-row="13" data-col="1">32</td>
                  <td data-row="13" data-col="2">32</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">67.48</td>
                  <td data-row="14" data-col="2">47.64</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Like with <code><a href="https://modelsummary.com/man/modelsummary.html">modelsummary()</a></code>, we can can name models and panels by naming elements of our nested list:</p>
<div class="cell">
<div class="sourceCode" id="cb62"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">panels</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="st">"Outcome: mpg"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="st">"(I)"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="fl">1</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="st">"(II)"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span>  <span class="op">)</span>,</span>
<span>  <span class="st">"Outcome: hp"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>    <span class="st">"(I)"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="fl">1</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span>,</span>
<span>    <span class="st">"(II)"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span>  <span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">panels</span>,</span>
<span>  shape <span class="op">=</span> <span class="st">"rbind"</span>,</span>
<span>  gof_map <span class="op">=</span> <span class="va">gm</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_su1w2dky4z0mdrzv5zgs(i, j, css_id) {
          var table = document.getElementById("tinytable_su1w2dky4z0mdrzv5zgs");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_su1w2dky4z0mdrzv5zgs(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_su1w2dky4z0mdrzv5zgs");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () { spanCell_su1w2dky4z0mdrzv5zgs(9, 0, 1, 3) })
      window.addEventListener('load', function () { spanCell_su1w2dky4z0mdrzv5zgs(1, 0, 1, 3) })
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 }, { i: '16', j: 2 },  ], css_id: 'tinytable_css_rtoququyrql7ap6lcm2f',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '12', j: 2 }, { i: '4', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '15', j: 2 },  ], css_id: 'tinytable_css_gz2cg5qvds1scx27cfnu',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_fc34q9kbbkg5fownnbj3',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_pxkucfqoy9xo6l1glp7b',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_vjggt40h5ca00nbx8uvt',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_bfwjn2cxy7mql1pxqr0k',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_su1w2dky4z0mdrzv5zgs(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_rtoququyrql7ap6lcm2f, .table th.tinytable_css_rtoququyrql7ap6lcm2f { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_gz2cg5qvds1scx27cfnu, .table th.tinytable_css_gz2cg5qvds1scx27cfnu { text-align: center; }
      .table td.tinytable_css_fc34q9kbbkg5fownnbj3, .table th.tinytable_css_fc34q9kbbkg5fownnbj3 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_pxkucfqoy9xo6l1glp7b, .table th.tinytable_css_pxkucfqoy9xo6l1glp7b { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_vjggt40h5ca00nbx8uvt, .table th.tinytable_css_vjggt40h5ca00nbx8uvt { text-align: left; }
      .table td.tinytable_css_bfwjn2cxy7mql1pxqr0k, .table th.tinytable_css_bfwjn2cxy7mql1pxqr0k { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_su1w2dky4z0mdrzv5zgs" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(I)</th>
                <th scope="col" data-row="0" data-col="2">(II)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Outcome: mpg</td>
                  <td data-row="1" data-col="1">Outcome: mpg</td>
                  <td data-row="1" data-col="2">Outcome: mpg</td>
                </tr>
<tr>
<td data-row="2" data-col="0">(Intercept)</td>
                  <td data-row="2" data-col="1">20.091</td>
                  <td data-row="2" data-col="2">-5.114</td>
                </tr>
<tr>
<td data-row="3" data-col="0"></td>
                  <td data-row="3" data-col="1">(1.065)</td>
                  <td data-row="3" data-col="2">(10.030)</td>
                </tr>
<tr>
<td data-row="4" data-col="0">qsec</td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">1.412</td>
                </tr>
<tr>
<td data-row="5" data-col="0"></td>
                  <td data-row="5" data-col="1"></td>
                  <td data-row="5" data-col="2">(0.559)</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2</td>
                  <td data-row="6" data-col="1">0.000</td>
                  <td data-row="6" data-col="2">0.175</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                  <td data-row="7" data-col="2">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">RMSE</td>
                  <td data-row="8" data-col="1">5.93</td>
                  <td data-row="8" data-col="2">5.39</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Outcome: hp</td>
                  <td data-row="9" data-col="1">Outcome: hp</td>
                  <td data-row="9" data-col="2">Outcome: hp</td>
                </tr>
<tr>
<td data-row="10" data-col="0">(Intercept)</td>
                  <td data-row="10" data-col="1">146.688</td>
                  <td data-row="10" data-col="2">631.704</td>
                </tr>
<tr>
<td data-row="11" data-col="0"></td>
                  <td data-row="11" data-col="1">(12.120)</td>
                  <td data-row="11" data-col="2">(88.700)</td>
                </tr>
<tr>
<td data-row="12" data-col="0">qsec</td>
                  <td data-row="12" data-col="1"></td>
                  <td data-row="12" data-col="2">-27.174</td>
                </tr>
<tr>
<td data-row="13" data-col="0"></td>
                  <td data-row="13" data-col="1"></td>
                  <td data-row="13" data-col="2">(4.946)</td>
                </tr>
<tr>
<td data-row="14" data-col="0">R2</td>
                  <td data-row="14" data-col="1">0.000</td>
                  <td data-row="14" data-col="2">0.502</td>
                </tr>
<tr>
<td data-row="15" data-col="0">Num.Obs.</td>
                  <td data-row="15" data-col="1">32</td>
                  <td data-row="15" data-col="2">32</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">67.48</td>
                  <td data-row="16" data-col="2">47.64</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="string-cbind-automatic-spanning-column-labels" class="level2"><h2 class="anchored" data-anchor-id="string-cbind-automatic-spanning-column-labels">String (“cbind”): Automatic spanning column labels</h2>
<p>When using the default <code>tinytable</code> backend, we can use a named nested list to automatically add spanning column labels to a table:</p>
<div class="cell">
<div class="sourceCode" id="cb63"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">panels</span>, shape <span class="op">=</span> <span class="st">"cbind"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_t1jxf8e96in3p5mn1wig(i, j, css_id) {
          var table = document.getElementById("tinytable_t1jxf8e96in3p5mn1wig");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_t1jxf8e96in3p5mn1wig(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_t1jxf8e96in3p5mn1wig");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '-1', j: 4 }, { i: '-1', j: 3 },  ], css_id: 'tinytable_css_iydvh0yp4h396wjfr86a',}, 
          { positions: [ { i: '12', j: 4 }, { i: '12', j: 1 }, { i: '12', j: 2 }, { i: '12', j: 3 },  ], css_id: 'tinytable_css_hh21xiwau1fz134k1mqz',}, 
          { positions: [ { i: '4', j: 3 }, { i: '4', j: 4 }, { i: '4', j: 1 }, { i: '4', j: 2 },  ], css_id: 'tinytable_css_2tvxmrym8eghgq9ishoy',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '11', j: 1 }, { i: '11', j: 2 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '2', j: 1 }, { i: '2', j: 2 }, { i: '2', j: 3 }, { i: '3', j: 3 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '10', j: 3 }, { i: '11', j: 3 }, { i: '1', j: 1 }, { i: '1', j: 2 }, { i: '1', j: 3 }, { i: '1', j: 4 }, { i: '2', j: 4 }, { i: '3', j: 4 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '7', j: 3 }, { i: '8', j: 3 }, { i: '9', j: 3 }, { i: '9', j: 4 }, { i: '10', j: 4 }, { i: '11', j: 4 }, { i: '7', j: 4 }, { i: '8', j: 4 }, { i: '5', j: 4 }, { i: '6', j: 4 },  ], css_id: 'tinytable_css_h57vr8cupxq4ac0vldba',}, 
          { positions: [ { i: '-1', j: 1 }, { i: '-1', j: 2 },  ], css_id: 'tinytable_css_wmsehqs5uc0tekuzsd2m',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 }, { i: '0', j: 3 }, { i: '0', j: 4 },  ], css_id: 'tinytable_css_d8rfm9lemo6x4w6gv2g4',}, 
          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_0phvajukm3yha9cx2csy',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_o7kpbywmglft1r4hl2mo',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 },  ], css_id: 'tinytable_css_gwp7yexz8iherae8efhy',}, 
          { positions: [ { i: '-1', j: 0 },  ], css_id: 'tinytable_css_wz161z1qxg7le014t8qw',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_9lvsr9j2jixfcd1nohj0',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_t1jxf8e96in3p5mn1wig(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_iydvh0yp4h396wjfr86a, .table th.tinytable_css_iydvh0yp4h396wjfr86a { text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_hh21xiwau1fz134k1mqz, .table th.tinytable_css_hh21xiwau1fz134k1mqz { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_2tvxmrym8eghgq9ishoy, .table th.tinytable_css_2tvxmrym8eghgq9ishoy { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_h57vr8cupxq4ac0vldba, .table th.tinytable_css_h57vr8cupxq4ac0vldba { text-align: center; }
      .table td.tinytable_css_wmsehqs5uc0tekuzsd2m, .table th.tinytable_css_wmsehqs5uc0tekuzsd2m { text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_d8rfm9lemo6x4w6gv2g4, .table th.tinytable_css_d8rfm9lemo6x4w6gv2g4 { text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_0phvajukm3yha9cx2csy, .table th.tinytable_css_0phvajukm3yha9cx2csy { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_o7kpbywmglft1r4hl2mo, .table th.tinytable_css_o7kpbywmglft1r4hl2mo { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_gwp7yexz8iherae8efhy, .table th.tinytable_css_gwp7yexz8iherae8efhy { text-align: left; }
      .table td.tinytable_css_wz161z1qxg7le014t8qw, .table th.tinytable_css_wz161z1qxg7le014t8qw { text-align: left; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_9lvsr9j2jixfcd1nohj0, .table th.tinytable_css_9lvsr9j2jixfcd1nohj0 { text-align: left; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_t1jxf8e96in3p5mn1wig" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead>
<tr>
<th scope="col" align="center" colspan="1" data-row="-1" data-col="0"> </th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="1">Outcome: mpg</th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="2">Outcome: hp</th>
</tr>
<tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(I)</th>
                <th scope="col" data-row="0" data-col="2">(II)</th>
                <th scope="col" data-row="0" data-col="3">(I) </th>
                <th scope="col" data-row="0" data-col="4">(II) </th>
              </tr>
</thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">20.091</td>
                  <td data-row="1" data-col="2">-5.114</td>
                  <td data-row="1" data-col="3">146.688</td>
                  <td data-row="1" data-col="4">631.704</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(1.065)</td>
                  <td data-row="2" data-col="2">(10.030)</td>
                  <td data-row="2" data-col="3">(12.120)</td>
                  <td data-row="2" data-col="4">(88.700)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">qsec</td>
                  <td data-row="3" data-col="1"></td>
                  <td data-row="3" data-col="2">1.412</td>
                  <td data-row="3" data-col="3"></td>
                  <td data-row="3" data-col="4">-27.174</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">(0.559)</td>
                  <td data-row="4" data-col="3"></td>
                  <td data-row="4" data-col="4">(4.946)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                  <td data-row="5" data-col="2">32</td>
                  <td data-row="5" data-col="3">32</td>
                  <td data-row="5" data-col="4">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2</td>
                  <td data-row="6" data-col="1">0.000</td>
                  <td data-row="6" data-col="2">0.175</td>
                  <td data-row="6" data-col="3">0.000</td>
                  <td data-row="6" data-col="4">0.502</td>
                </tr>
<tr>
<td data-row="7" data-col="0">R2 Adj.</td>
                  <td data-row="7" data-col="1">0.000</td>
                  <td data-row="7" data-col="2">0.148</td>
                  <td data-row="7" data-col="3">0.000</td>
                  <td data-row="7" data-col="4">0.485</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">208.8</td>
                  <td data-row="8" data-col="2">204.6</td>
                  <td data-row="8" data-col="3">364.4</td>
                  <td data-row="8" data-col="4">344.1</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">211.7</td>
                  <td data-row="9" data-col="2">209.0</td>
                  <td data-row="9" data-col="3">367.3</td>
                  <td data-row="9" data-col="4">348.5</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-102.378</td>
                  <td data-row="10" data-col="2">-99.294</td>
                  <td data-row="10" data-col="3">-180.186</td>
                  <td data-row="10" data-col="4">-169.045</td>
                </tr>
<tr>
<td data-row="11" data-col="0">F</td>
                  <td data-row="11" data-col="1"></td>
                  <td data-row="11" data-col="2">6.377</td>
                  <td data-row="11" data-col="3"></td>
                  <td data-row="11" data-col="4">30.190</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1">5.93</td>
                  <td data-row="12" data-col="2">5.39</td>
                  <td data-row="12" data-col="3">67.48</td>
                  <td data-row="12" data-col="4">47.64</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="renaming-estimates-and-statistics" class="level2"><h2 class="anchored" data-anchor-id="renaming-estimates-and-statistics">Renaming estimates and statistics</h2>
<p>When statistics are displayed in different columns, users may want control over the statistic names. To do so, we specify the <code>estimate</code> and <code>statistic</code> as named vectors:</p>
<div class="cell">
<div class="sourceCode" id="cb64"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>    <span class="va">mod</span>, </span>
<span>    estimate <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"$\\hat{\\beta}$"</span> <span class="op">=</span> <span class="st">"estimate"</span><span class="op">)</span>,</span>
<span>    statistic <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"$\\sigma_{\\hat{\\beta}}$"</span> <span class="op">=</span> <span class="st">"std.error"</span><span class="op">)</span>,</span>
<span>    shape <span class="op">=</span> <span class="va">term</span> <span class="op">~</span> <span class="va">model</span> <span class="op">+</span> <span class="va">statistic</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_lgrw243xm8sqc3afqssw(i, j, css_id) {
          var table = document.getElementById("tinytable_lgrw243xm8sqc3afqssw");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_lgrw243xm8sqc3afqssw(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_lgrw243xm8sqc3afqssw");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '-1', j: 2 },  ], css_id: 'tinytable_css_62r8b6a8ohsq376inenw',}, 
          { positions: [ { i: '11', j: 1 }, { i: '11', j: 2 },  ], css_id: 'tinytable_css_u0ppvtag23jvp0873acg',}, 
          { positions: [ { i: '3', j: 1 }, { i: '3', j: 2 },  ], css_id: 'tinytable_css_buu86dbyh8vhxp3dkz3k',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '7', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '2', j: 2 }, { i: '4', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '6', j: 2 }, { i: '8', j: 1 }, { i: '4', j: 2 }, { i: '1', j: 2 }, { i: '10', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '5', j: 2 }, { i: '9', j: 2 },  ], css_id: 'tinytable_css_aktpcjf0j9j8qio4qjl9',}, 
          { positions: [ { i: '-1', j: 1 },  ], css_id: 'tinytable_css_7idvvdn9qf6zhtpkd5cd',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_anevyp46hsxn6j4sf59l',}, 
          { positions: [ { i: '11', j: 0 },  ], css_id: 'tinytable_css_jlp6hiximiz0wqzgdkox',}, 
          { positions: [ { i: '3', j: 0 },  ], css_id: 'tinytable_css_kpl2ioz75cx0dd4znjh6',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '7', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 },  ], css_id: 'tinytable_css_20f7kmepn2ik170a7qdp',}, 
          { positions: [ { i: '-1', j: 0 },  ], css_id: 'tinytable_css_h4vwzptifudey3ixw6ke',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_f1ednqqu6q0bdqmu2irj',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_lgrw243xm8sqc3afqssw(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_62r8b6a8ohsq376inenw, .table th.tinytable_css_62r8b6a8ohsq376inenw { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_u0ppvtag23jvp0873acg, .table th.tinytable_css_u0ppvtag23jvp0873acg { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_buu86dbyh8vhxp3dkz3k, .table th.tinytable_css_buu86dbyh8vhxp3dkz3k { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_aktpcjf0j9j8qio4qjl9, .table th.tinytable_css_aktpcjf0j9j8qio4qjl9 { text-align: center; }
      .table td.tinytable_css_7idvvdn9qf6zhtpkd5cd, .table th.tinytable_css_7idvvdn9qf6zhtpkd5cd { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_anevyp46hsxn6j4sf59l, .table th.tinytable_css_anevyp46hsxn6j4sf59l { text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_jlp6hiximiz0wqzgdkox, .table th.tinytable_css_jlp6hiximiz0wqzgdkox { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_kpl2ioz75cx0dd4znjh6, .table th.tinytable_css_kpl2ioz75cx0dd4znjh6 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_20f7kmepn2ik170a7qdp, .table th.tinytable_css_20f7kmepn2ik170a7qdp { text-align: left; }
      .table td.tinytable_css_h4vwzptifudey3ixw6ke, .table th.tinytable_css_h4vwzptifudey3ixw6ke { text-align: left; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_f1ednqqu6q0bdqmu2irj, .table th.tinytable_css_f1ednqqu6q0bdqmu2irj { text-align: left; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_lgrw243xm8sqc3afqssw" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead>
<tr>
<th scope="col" align="center" colspan="1" data-row="-1" data-col="0"> </th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="1">(1)</th>
</tr>
<tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">$\hat{\beta}$</th>
                <th scope="col" data-row="0" data-col="2">$\sigma_{\hat{\beta}}$</th>
              </tr>
</thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">26.664</td>
                  <td data-row="1" data-col="2">0.972</td>
                </tr>
<tr>
<td data-row="2" data-col="0">factor(cyl)6</td>
                  <td data-row="2" data-col="1">-6.921</td>
                  <td data-row="2" data-col="2">1.558</td>
                </tr>
<tr>
<td data-row="3" data-col="0">factor(cyl)8</td>
                  <td data-row="3" data-col="1">-11.564</td>
                  <td data-row="3" data-col="2">1.299</td>
                </tr>
<tr>
<td data-row="4" data-col="0">Num.Obs.</td>
                  <td data-row="4" data-col="1">32</td>
                  <td data-row="4" data-col="2"></td>
                </tr>
<tr>
<td data-row="5" data-col="0">R2</td>
                  <td data-row="5" data-col="1">0.732</td>
                  <td data-row="5" data-col="2"></td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2 Adj.</td>
                  <td data-row="6" data-col="1">0.714</td>
                  <td data-row="6" data-col="2"></td>
                </tr>
<tr>
<td data-row="7" data-col="0">AIC</td>
                  <td data-row="7" data-col="1">170.6</td>
                  <td data-row="7" data-col="2"></td>
                </tr>
<tr>
<td data-row="8" data-col="0">BIC</td>
                  <td data-row="8" data-col="1">176.4</td>
                  <td data-row="8" data-col="2"></td>
                </tr>
<tr>
<td data-row="9" data-col="0">Log.Lik.</td>
                  <td data-row="9" data-col="1">-81.282</td>
                  <td data-row="9" data-col="2"></td>
                </tr>
<tr>
<td data-row="10" data-col="0">F</td>
                  <td data-row="10" data-col="1">39.698</td>
                  <td data-row="10" data-col="2"></td>
                </tr>
<tr>
<td data-row="11" data-col="0">RMSE</td>
                  <td data-row="11" data-col="1">3.07</td>
                  <td data-row="11" data-col="2"></td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<section id="fixest" class="level3"><h3 class="anchored" data-anchor-id="fixest"><code>fixest</code></h3>
<p>The <code>fixest</code> package offers powerful tools to estimate multiple models using a concise syntax. <code>fixest</code> functions are also convenient because they return named lists of models which are easy to subset and manipulate using standard <code>R</code> functions like <code>grepl</code>.</p>
<p>For example, to introduce regressors in stepwise fashion, and to estimate models on different subsets of the data, we can do:</p>
<div class="cell">
<div class="sourceCode" id="cb65"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># estimate 4 models</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://lrberge.github.io/fixest/">fixest</a></span><span class="op">)</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://lrberge.github.io/fixest/reference/feols.html">feols</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">hp</span>, <span class="va">mpg</span><span class="op">)</span> <span class="op">~</span> <span class="fu">csw</span><span class="op">(</span><span class="va">qsec</span>, <span class="va">drat</span><span class="op">)</span> <span class="op">|</span> <span class="va">gear</span>,</span>
<span>  data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># select models with different outcome variables</span></span>
<span><span class="va">panels</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="st">"Miles per gallon"</span> <span class="op">=</span> <span class="va">mod</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grepl</a></span><span class="op">(</span><span class="st">"mpg"</span>, <span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span><span class="op">)</span><span class="op">]</span>,</span>
<span>  <span class="st">"Horsepower"</span> <span class="op">=</span> <span class="va">mod</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grepl</a></span><span class="op">(</span><span class="st">"hp"</span>, <span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span><span class="op">)</span><span class="op">]</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">panels</span>,</span>
<span>  shape <span class="op">=</span> <span class="st">"rcollapse"</span>,</span>
<span>  gof_omit <span class="op">=</span> <span class="st">"IC|R2"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_3n3ilz9x139cwxu5mf4s(i, j, css_id) {
          var table = document.getElementById("tinytable_3n3ilz9x139cwxu5mf4s");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_3n3ilz9x139cwxu5mf4s(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_3n3ilz9x139cwxu5mf4s");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () { spanCell_3n3ilz9x139cwxu5mf4s(7, 0, 1, 3) })
      window.addEventListener('load', function () { spanCell_3n3ilz9x139cwxu5mf4s(1, 0, 1, 3) })
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '15', j: 1 }, { i: '15', j: 2 },  ], css_id: 'tinytable_css_4tlzqgyx0ljqomveisn9',}, 
          { positions: [ { i: '10', j: 1 }, { i: '10', j: 2 },  ], css_id: 'tinytable_css_g2xy7m1jqpdnh7iyddh4',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '7', j: 2 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '12', j: 2 }, { i: '3', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '11', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '14', j: 2 }, { i: '13', j: 2 },  ], css_id: 'tinytable_css_tyfl8ywpsguojjl3rtl0',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_oezyxwjy0j29fwl7rsow',}, 
          { positions: [ { i: '15', j: 0 },  ], css_id: 'tinytable_css_jlypdg4p0fb3viefplt8',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_p92c7ohcucpmkoet33d3',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_2pxxq684al3i0qagbwep',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_bxsz90ccycy8v4u99im4',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_3n3ilz9x139cwxu5mf4s(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_4tlzqgyx0ljqomveisn9, .table th.tinytable_css_4tlzqgyx0ljqomveisn9 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_g2xy7m1jqpdnh7iyddh4, .table th.tinytable_css_g2xy7m1jqpdnh7iyddh4 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_tyfl8ywpsguojjl3rtl0, .table th.tinytable_css_tyfl8ywpsguojjl3rtl0 { text-align: center; }
      .table td.tinytable_css_oezyxwjy0j29fwl7rsow, .table th.tinytable_css_oezyxwjy0j29fwl7rsow { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_jlypdg4p0fb3viefplt8, .table th.tinytable_css_jlypdg4p0fb3viefplt8 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_p92c7ohcucpmkoet33d3, .table th.tinytable_css_p92c7ohcucpmkoet33d3 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_2pxxq684al3i0qagbwep, .table th.tinytable_css_2pxxq684al3i0qagbwep { text-align: left; }
      .table td.tinytable_css_bxsz90ccycy8v4u99im4, .table th.tinytable_css_bxsz90ccycy8v4u99im4 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_3n3ilz9x139cwxu5mf4s" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Miles per gallon</td>
                  <td data-row="1" data-col="1">Miles per gallon</td>
                  <td data-row="1" data-col="2">Miles per gallon</td>
                </tr>
<tr>
<td data-row="2" data-col="0">qsec</td>
                  <td data-row="2" data-col="1">1.436</td>
                  <td data-row="2" data-col="2">1.519</td>
                </tr>
<tr>
<td data-row="3" data-col="0"></td>
                  <td data-row="3" data-col="1">(0.594)</td>
                  <td data-row="3" data-col="2">(0.529)</td>
                </tr>
<tr>
<td data-row="4" data-col="0">drat</td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">5.765</td>
                </tr>
<tr>
<td data-row="5" data-col="0"></td>
                  <td data-row="5" data-col="1"></td>
                  <td data-row="5" data-col="2">(2.381)</td>
                </tr>
<tr>
<td data-row="6" data-col="0">RMSE</td>
                  <td data-row="6" data-col="1">4.03</td>
                  <td data-row="6" data-col="2">3.67</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Horsepower</td>
                  <td data-row="7" data-col="1">Horsepower</td>
                  <td data-row="7" data-col="2">Horsepower</td>
                </tr>
<tr>
<td data-row="8" data-col="0">qsec</td>
                  <td data-row="8" data-col="1">-22.175</td>
                  <td data-row="8" data-col="2">-22.676</td>
                </tr>
<tr>
<td data-row="9" data-col="0"></td>
                  <td data-row="9" data-col="1">(12.762)</td>
                  <td data-row="9" data-col="2">(13.004)</td>
                </tr>
<tr>
<td data-row="10" data-col="0">drat</td>
                  <td data-row="10" data-col="1"></td>
                  <td data-row="10" data-col="2">-35.106</td>
                </tr>
<tr>
<td data-row="11" data-col="0"></td>
                  <td data-row="11" data-col="1"></td>
                  <td data-row="11" data-col="2">(28.509)</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1">40.45</td>
                  <td data-row="12" data-col="2">39.14</td>
                </tr>
<tr>
<td data-row="13" data-col="0">Num.Obs.</td>
                  <td data-row="13" data-col="1">32</td>
                  <td data-row="13" data-col="2">32</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Std.Errors</td>
                  <td data-row="14" data-col="1">by: gear</td>
                  <td data-row="14" data-col="2">by: gear</td>
                </tr>
<tr>
<td data-row="15" data-col="0">FE: gear</td>
                  <td data-row="15" data-col="1">X</td>
                  <td data-row="15" data-col="2">X</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>We can use all the typical extension systems to add information, such as the mean of the dependent variable:</p>
<div class="cell">
<div class="sourceCode" id="cb66"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">glance_custom.fixest</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span>, <span class="va">...</span><span class="op">)</span> <span class="op">{</span></span>
<span>  <span class="va">dv</span> <span class="op">&lt;-</span> <span class="fu">insight</span><span class="fu">::</span><span class="fu"><a href="https://easystats.github.io/insight/reference/get_response.html">get_response</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></span>
<span>  <span class="va">dv</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/sprintf.html">sprintf</a></span><span class="op">(</span><span class="st">"%.2f"</span>, <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">dv</span>, na.rm <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></span>
<span>  <span class="fu">data.table</span><span class="fu">::</span><span class="fu"><a href="https://rdatatable.gitlab.io/data.table/reference/data.table.html">data.table</a></span><span class="op">(</span>`Mean of DV` <span class="op">=</span> <span class="va">dv</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">panels</span>,</span>
<span>  shape <span class="op">=</span> <span class="st">"rcollapse"</span>,</span>
<span>  gof_omit <span class="op">=</span> <span class="st">"IC|R2"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_4aill34x4ko74drhg6o9(i, j, css_id) {
          var table = document.getElementById("tinytable_4aill34x4ko74drhg6o9");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_4aill34x4ko74drhg6o9(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_4aill34x4ko74drhg6o9");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () { spanCell_4aill34x4ko74drhg6o9(8, 0, 1, 3) })
      window.addEventListener('load', function () { spanCell_4aill34x4ko74drhg6o9(1, 0, 1, 3) })
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '17', j: 1 }, { i: '17', j: 2 },  ], css_id: 'tinytable_css_tfaet74nv3nksiqz38sy',}, 
          { positions: [ { i: '12', j: 2 }, { i: '12', j: 1 },  ], css_id: 'tinytable_css_fa05xutyt4u4k7x4o7zk',}, 
          { positions: [ { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '1', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '7', j: 2 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '16', j: 1 }, { i: '3', j: 2 }, { i: '5', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '11', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '15', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '16', j: 2 }, { i: '13', j: 2 }, { i: '14', j: 2 },  ], css_id: 'tinytable_css_3fgmwsjqi4x9foa6dgyy',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_0al0lux969jjdd8d7vrs',}, 
          { positions: [ { i: '17', j: 0 },  ], css_id: 'tinytable_css_v8wceygu13f39gfvchyl',}, 
          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_qq5kkqo19bruc4mekhav',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '16', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_qxpepcfr99mrx70kjjzp',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_qow1wmtugsgwjds45f85',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_4aill34x4ko74drhg6o9(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_tfaet74nv3nksiqz38sy, .table th.tinytable_css_tfaet74nv3nksiqz38sy { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_fa05xutyt4u4k7x4o7zk, .table th.tinytable_css_fa05xutyt4u4k7x4o7zk { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_3fgmwsjqi4x9foa6dgyy, .table th.tinytable_css_3fgmwsjqi4x9foa6dgyy { text-align: center; }
      .table td.tinytable_css_0al0lux969jjdd8d7vrs, .table th.tinytable_css_0al0lux969jjdd8d7vrs { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_v8wceygu13f39gfvchyl, .table th.tinytable_css_v8wceygu13f39gfvchyl { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_qq5kkqo19bruc4mekhav, .table th.tinytable_css_qq5kkqo19bruc4mekhav { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_qxpepcfr99mrx70kjjzp, .table th.tinytable_css_qxpepcfr99mrx70kjjzp { text-align: left; }
      .table td.tinytable_css_qow1wmtugsgwjds45f85, .table th.tinytable_css_qow1wmtugsgwjds45f85 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_4aill34x4ko74drhg6o9" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">Miles per gallon</td>
                  <td data-row="1" data-col="1">Miles per gallon</td>
                  <td data-row="1" data-col="2">Miles per gallon</td>
                </tr>
<tr>
<td data-row="2" data-col="0">qsec</td>
                  <td data-row="2" data-col="1">1.436</td>
                  <td data-row="2" data-col="2">1.519</td>
                </tr>
<tr>
<td data-row="3" data-col="0"></td>
                  <td data-row="3" data-col="1">(0.594)</td>
                  <td data-row="3" data-col="2">(0.529)</td>
                </tr>
<tr>
<td data-row="4" data-col="0">drat</td>
                  <td data-row="4" data-col="1"></td>
                  <td data-row="4" data-col="2">5.765</td>
                </tr>
<tr>
<td data-row="5" data-col="0"></td>
                  <td data-row="5" data-col="1"></td>
                  <td data-row="5" data-col="2">(2.381)</td>
                </tr>
<tr>
<td data-row="6" data-col="0">RMSE</td>
                  <td data-row="6" data-col="1">4.03</td>
                  <td data-row="6" data-col="2">3.67</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Mean of DV</td>
                  <td data-row="7" data-col="1">20.09</td>
                  <td data-row="7" data-col="2">20.09</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Horsepower</td>
                  <td data-row="8" data-col="1">Horsepower</td>
                  <td data-row="8" data-col="2">Horsepower</td>
                </tr>
<tr>
<td data-row="9" data-col="0">qsec</td>
                  <td data-row="9" data-col="1">-22.175</td>
                  <td data-row="9" data-col="2">-22.676</td>
                </tr>
<tr>
<td data-row="10" data-col="0"></td>
                  <td data-row="10" data-col="1">(12.762)</td>
                  <td data-row="10" data-col="2">(13.004)</td>
                </tr>
<tr>
<td data-row="11" data-col="0">drat</td>
                  <td data-row="11" data-col="1"></td>
                  <td data-row="11" data-col="2">-35.106</td>
                </tr>
<tr>
<td data-row="12" data-col="0"></td>
                  <td data-row="12" data-col="1"></td>
                  <td data-row="12" data-col="2">(28.509)</td>
                </tr>
<tr>
<td data-row="13" data-col="0">RMSE</td>
                  <td data-row="13" data-col="1">40.45</td>
                  <td data-row="13" data-col="2">39.14</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Mean of DV</td>
                  <td data-row="14" data-col="1">146.69</td>
                  <td data-row="14" data-col="2">146.69</td>
                </tr>
<tr>
<td data-row="15" data-col="0">Num.Obs.</td>
                  <td data-row="15" data-col="1">32</td>
                  <td data-row="15" data-col="2">32</td>
                </tr>
<tr>
<td data-row="16" data-col="0">Std.Errors</td>
                  <td data-row="16" data-col="1">by: gear</td>
                  <td data-row="16" data-col="2">by: gear</td>
                </tr>
<tr>
<td data-row="17" data-col="0">FE: gear</td>
                  <td data-row="17" data-col="1">X</td>
                  <td data-row="17" data-col="2">X</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
<div class="sourceCode" id="cb67"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/rm.html">rm</a></span><span class="op">(</span><span class="st">"glance_custom.fixest"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section></section></section><section id="align" class="level1"><h1><code>align</code></h1>
<p>By default, <code>modelsummary</code> will align the first column (with coefficient names) to the left, and will center the results columns. To change this default, you can use the align argument, which accepts a string of the same length as the number of columns:</p>
<div class="cell">
<div class="sourceCode" id="cb68"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, align<span class="op">=</span><span class="st">"lrrrrr"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Users who produce PDF documents using Rmarkdown or LaTeX can also align values on the decimal dot by using the character “d” in the <code>align</code> argument:</p>
<div class="cell">
<div class="sourceCode" id="cb69"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, align<span class="op">=</span><span class="st">"lddddd"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>See <code><a href="https://modelsummary.com/man/modelsummary.html">?modelsummary</a></code> for a list of commands which need to appear in the LaTeX preamble to compile tables like this one.</p>
</section><section id="notes" class="level1"><h1><code>notes</code></h1>
<p>Add notes to the bottom of your table:</p>
<div class="sourceCode" id="cb70"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, </span>
<span>   notes <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">'Text of the first note.'</span>, </span>
<span>                <span class="st">'Text of the second note.'</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section><section id="title" class="level1"><h1><code>title</code></h1>
<p>You can add a title to your table as follows:</p>
<div class="sourceCode" id="cb71"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, title <span class="op">=</span> <span class="st">'This is a title for my table.'</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section><section id="add_rows" class="level1"><h1><code>add_rows</code></h1>
<p>Use the <code>add_rows</code> argument to add rows manually to a table. For example, let’s say you estimate two models with a factor variables and you want to insert (a) an empty line to identify the category of reference, and (b) customized information at the bottom of the table:</p>
<div class="cell">
<div class="sourceCode" id="cb72"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">models</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="va">models</span><span class="op">[[</span><span class="st">'OLS'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="va">models</span><span class="op">[[</span><span class="st">'Logit'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/glm.html">glm</a></span><span class="op">(</span><span class="va">am</span> <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span>, <span class="va">mtcars</span>, family <span class="op">=</span> <span class="va">binomial</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>We create a data.frame with the same number of columns as the summary table. Then, we define a “position” attribute to specify where the new rows should be inserted in the table. Finally, we pass this data.frame to the <code>add_rows</code> argument:</p>
<div class="cell">
<div class="sourceCode" id="cb73"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://tibble.tidyverse.org/">tibble</a></span><span class="op">)</span></span>
<span><span class="va">rows</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span><span class="op">(</span><span class="op">~</span><span class="va">term</span>,          <span class="op">~</span><span class="va">OLS</span>,  <span class="op">~</span><span class="va">Logit</span>,</span>
<span>                <span class="st">'factor(cyl)4'</span>, <span class="st">'-'</span>,   <span class="st">'-'</span>,</span>
<span>                <span class="st">'Info'</span>,         <span class="st">'???'</span>, <span class="st">'XYZ'</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/attr.html">attr</a></span><span class="op">(</span><span class="va">rows</span>, <span class="st">'position'</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">3</span>, <span class="fl">9</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">models</span>, add_rows <span class="op">=</span> <span class="va">rows</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_h6bmxbyhcov45p6b5z1l(i, j, css_id) {
          var table = document.getElementById("tinytable_h6bmxbyhcov45p6b5z1l");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_h6bmxbyhcov45p6b5z1l(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_h6bmxbyhcov45p6b5z1l");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 }, { i: '16', j: 2 },  ], css_id: 'tinytable_css_xn4ma2hkkczl8herdqok',}, 
          { positions: [ { i: '7', j: 1 }, { i: '7', j: 2 },  ], css_id: 'tinytable_css_wyhrfhrv5ktq1ho4zpwn',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '3', j: 2 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '12', j: 2 }, { i: '4', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '11', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '15', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '13', j: 2 }, { i: '14', j: 2 },  ], css_id: 'tinytable_css_leg6vy8lyuj5h32ggmy0',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_o85e8iab52lbd1o315yo',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_cvw30proe7r5bi3zyrnc',}, 
          { positions: [ { i: '7', j: 0 },  ], css_id: 'tinytable_css_0bjffa4574pvm2bjwyr6',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '11', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '15', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 },  ], css_id: 'tinytable_css_cx8dbqmc2nzchcrnt1ui',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_c9xijmhl0xfjx7cyf0pk',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_h6bmxbyhcov45p6b5z1l(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_xn4ma2hkkczl8herdqok, .table th.tinytable_css_xn4ma2hkkczl8herdqok { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_wyhrfhrv5ktq1ho4zpwn, .table th.tinytable_css_wyhrfhrv5ktq1ho4zpwn { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_leg6vy8lyuj5h32ggmy0, .table th.tinytable_css_leg6vy8lyuj5h32ggmy0 { text-align: center; }
      .table td.tinytable_css_o85e8iab52lbd1o315yo, .table th.tinytable_css_o85e8iab52lbd1o315yo { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_cvw30proe7r5bi3zyrnc, .table th.tinytable_css_cvw30proe7r5bi3zyrnc { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_0bjffa4574pvm2bjwyr6, .table th.tinytable_css_0bjffa4574pvm2bjwyr6 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_cx8dbqmc2nzchcrnt1ui, .table th.tinytable_css_cx8dbqmc2nzchcrnt1ui { text-align: left; }
      .table td.tinytable_css_c9xijmhl0xfjx7cyf0pk, .table th.tinytable_css_c9xijmhl0xfjx7cyf0pk { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_h6bmxbyhcov45p6b5z1l" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">OLS</th>
                <th scope="col" data-row="0" data-col="2">Logit</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">26.664</td>
                  <td data-row="1" data-col="2">0.981</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.972)</td>
                  <td data-row="2" data-col="2">(0.677)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">factor(cyl)4</td>
                  <td data-row="3" data-col="1">-</td>
                  <td data-row="3" data-col="2">-</td>
                </tr>
<tr>
<td data-row="4" data-col="0">factor(cyl)6</td>
                  <td data-row="4" data-col="1">-6.921</td>
                  <td data-row="4" data-col="2">-1.269</td>
                </tr>
<tr>
<td data-row="5" data-col="0"></td>
                  <td data-row="5" data-col="1">(1.558)</td>
                  <td data-row="5" data-col="2">(1.021)</td>
                </tr>
<tr>
<td data-row="6" data-col="0">factor(cyl)8</td>
                  <td data-row="6" data-col="1">-11.564</td>
                  <td data-row="6" data-col="2">-2.773</td>
                </tr>
<tr>
<td data-row="7" data-col="0"></td>
                  <td data-row="7" data-col="1">(1.299)</td>
                  <td data-row="7" data-col="2">(1.021)</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Num.Obs.</td>
                  <td data-row="8" data-col="1">32</td>
                  <td data-row="8" data-col="2">32</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Info</td>
                  <td data-row="9" data-col="1">???</td>
                  <td data-row="9" data-col="2">XYZ</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2</td>
                  <td data-row="10" data-col="1">0.732</td>
                  <td data-row="10" data-col="2"></td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Adj.</td>
                  <td data-row="11" data-col="1">0.714</td>
                  <td data-row="11" data-col="2"></td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">170.6</td>
                  <td data-row="12" data-col="2">39.9</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">176.4</td>
                  <td data-row="13" data-col="2">44.3</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Log.Lik.</td>
                  <td data-row="14" data-col="1">-81.282</td>
                  <td data-row="14" data-col="2">-16.967</td>
                </tr>
<tr>
<td data-row="15" data-col="0">F</td>
                  <td data-row="15" data-col="1">39.698</td>
                  <td data-row="15" data-col="2">3.691</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">3.07</td>
                  <td data-row="16" data-col="2">0.42</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="exponentiate" class="level1"><h1><code>exponentiate</code></h1>
<p>We can exponentiate their estimates using the <code>exponentiate</code> argument:</p>
<div class="cell">
<div class="sourceCode" id="cb74"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod_logit</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/glm.html">glm</a></span><span class="op">(</span><span class="va">am</span> <span class="op">~</span> <span class="va">mpg</span>, data <span class="op">=</span> <span class="va">mtcars</span>, family <span class="op">=</span> <span class="va">binomial</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod_logit</span>, exponentiate <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_mvf100du4mztf5376oyf(i, j, css_id) {
          var table = document.getElementById("tinytable_mvf100du4mztf5376oyf");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_mvf100du4mztf5376oyf(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_mvf100du4mztf5376oyf");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 1 },  ], css_id: 'tinytable_css_yp4x9bpjbujziynujvfb',}, 
          { positions: [ { i: '4', j: 1 },  ], css_id: 'tinytable_css_un1esfqxliopyehojovi',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '8', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 },  ], css_id: 'tinytable_css_lk30lxsdujck01ba2dvc',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_4fmvs1n6y9t0msddhosh',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_1y27goey8v65i9fsx1jn',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_sw2xdy1e9qyo04idm6bf',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 },  ], css_id: 'tinytable_css_57fxp0yu87vl6svn08ao',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_86442yj1fdagzv9wgi9w',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_mvf100du4mztf5376oyf(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_yp4x9bpjbujziynujvfb, .table th.tinytable_css_yp4x9bpjbujziynujvfb { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_un1esfqxliopyehojovi, .table th.tinytable_css_un1esfqxliopyehojovi { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_lk30lxsdujck01ba2dvc, .table th.tinytable_css_lk30lxsdujck01ba2dvc { text-align: center; }
      .table td.tinytable_css_4fmvs1n6y9t0msddhosh, .table th.tinytable_css_4fmvs1n6y9t0msddhosh { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_1y27goey8v65i9fsx1jn, .table th.tinytable_css_1y27goey8v65i9fsx1jn { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_sw2xdy1e9qyo04idm6bf, .table th.tinytable_css_sw2xdy1e9qyo04idm6bf { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_57fxp0yu87vl6svn08ao, .table th.tinytable_css_57fxp0yu87vl6svn08ao { text-align: left; }
      .table td.tinytable_css_86442yj1fdagzv9wgi9w, .table th.tinytable_css_86442yj1fdagzv9wgi9w { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_mvf100du4mztf5376oyf" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">0.001</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.003)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">mpg</td>
                  <td data-row="3" data-col="1">1.359</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.156)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">AIC</td>
                  <td data-row="6" data-col="1">33.7</td>
                </tr>
<tr>
<td data-row="7" data-col="0">BIC</td>
                  <td data-row="7" data-col="1">36.6</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Log.Lik.</td>
                  <td data-row="8" data-col="1">-14.838</td>
                </tr>
<tr>
<td data-row="9" data-col="0">F</td>
                  <td data-row="9" data-col="1">7.148</td>
                </tr>
<tr>
<td data-row="10" data-col="0">RMSE</td>
                  <td data-row="10" data-col="1">0.39</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>We can also present exponentiated and standard models side by side by using a logical vector:</p>
<div class="cell">
<div class="sourceCode" id="cb75"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod_logit</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="va">mod_logit</span>, <span class="va">mod_logit</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod_logit</span>, exponentiate <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="cn">TRUE</span>, <span class="cn">FALSE</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_dpwl2xvctzuju11wacsw(i, j, css_id) {
          var table = document.getElementById("tinytable_dpwl2xvctzuju11wacsw");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_dpwl2xvctzuju11wacsw(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_dpwl2xvctzuju11wacsw");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 1 }, { i: '10', j: 2 },  ], css_id: 'tinytable_css_0otrqsjhav4eafclc0oi',}, 
          { positions: [ { i: '4', j: 2 }, { i: '4', j: 1 },  ], css_id: 'tinytable_css_ouxrpqqyl8cu3o74dbdh',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '8', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '3', j: 1 }, { i: '1', j: 2 }, { i: '9', j: 1 }, { i: '3', j: 2 }, { i: '7', j: 1 }, { i: '5', j: 2 }, { i: '2', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '6', j: 2 },  ], css_id: 'tinytable_css_samei1jde189d7s67dq5',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_k7ldgiz75iu37u18801t',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_2z1n0v04qlml88b7qt6d',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_c3bh7q7gkvrjxwingckx',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 },  ], css_id: 'tinytable_css_d2nwl9xtzu0z0j72pk69',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_xmebbvodrxbvga8e9ixb',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_dpwl2xvctzuju11wacsw(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_0otrqsjhav4eafclc0oi, .table th.tinytable_css_0otrqsjhav4eafclc0oi { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ouxrpqqyl8cu3o74dbdh, .table th.tinytable_css_ouxrpqqyl8cu3o74dbdh { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_samei1jde189d7s67dq5, .table th.tinytable_css_samei1jde189d7s67dq5 { text-align: center; }
      .table td.tinytable_css_k7ldgiz75iu37u18801t, .table th.tinytable_css_k7ldgiz75iu37u18801t { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_2z1n0v04qlml88b7qt6d, .table th.tinytable_css_2z1n0v04qlml88b7qt6d { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_c3bh7q7gkvrjxwingckx, .table th.tinytable_css_c3bh7q7gkvrjxwingckx { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_d2nwl9xtzu0z0j72pk69, .table th.tinytable_css_d2nwl9xtzu0z0j72pk69 { text-align: left; }
      .table td.tinytable_css_xmebbvodrxbvga8e9ixb, .table th.tinytable_css_xmebbvodrxbvga8e9ixb { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_dpwl2xvctzuju11wacsw" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">0.001</td>
                  <td data-row="1" data-col="2">-6.604</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.003)</td>
                  <td data-row="2" data-col="2">(2.351)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">mpg</td>
                  <td data-row="3" data-col="1">1.359</td>
                  <td data-row="3" data-col="2">0.307</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.156)</td>
                  <td data-row="4" data-col="2">(0.115)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                  <td data-row="5" data-col="2">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">AIC</td>
                  <td data-row="6" data-col="1">33.7</td>
                  <td data-row="6" data-col="2">33.7</td>
                </tr>
<tr>
<td data-row="7" data-col="0">BIC</td>
                  <td data-row="7" data-col="1">36.6</td>
                  <td data-row="7" data-col="2">36.6</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Log.Lik.</td>
                  <td data-row="8" data-col="1">-14.838</td>
                  <td data-row="8" data-col="2">-14.838</td>
                </tr>
<tr>
<td data-row="9" data-col="0">F</td>
                  <td data-row="9" data-col="1">7.148</td>
                  <td data-row="9" data-col="2">7.148</td>
                </tr>
<tr>
<td data-row="10" data-col="0">RMSE</td>
                  <td data-row="10" data-col="1">0.39</td>
                  <td data-row="10" data-col="2">0.39</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="additional-arguments" class="level1"><h1>
<code>...</code> Additional arguments</h1>
<p>All arguments passed by the user to a <code>modelsummary</code> function are pushed forward in two other functions:</p>
<ol type="1">
<li>The function which extracts model estimates.
<ul>
<li>By default, additional arguments are pushed forward to <code><a href="https://easystats.github.io/parameters/reference/model_parameters.html">parameters::parameters</a></code> and <code><a href="https://easystats.github.io/performance/reference/model_performance.html">performance::performance</a></code>. Users can also can also use a different “backend” to extract information from model objects: the <code>broom</code> package. See <a href="#sec-global-options" class="quarto-xref">Section&nbsp;24</a> section on how to do that. With these packages, other arguments are available, such as the <code>metrics</code> argument. Please refer to these package’s documentation to details.</li>
</ul>
</li>
<li>The table-making functions.
<ul>
<li>By default, additional arguments are pushed forward to <code><a href="https://rdrr.io/pkg/kableExtra/man/kbl.html">kableExtra::kbl</a></code>, but users can use a different table-making function by setting the <code>output</code> argument to a different value such as <code>"gt"</code>, <code>"flextable"</code>, or <code>"huxtable"</code>.</li>
<li>See <a href="https://modelsummary.com/vignettes/appearance.html">the Appearance vignette</a> for examples.</li>
</ul>
</li>
</ol>
<p>All arguments passed supported by these functions are thus automatically available directly in <code>modelsummary</code>, <code>modelplot</code>, and the <code>datasummary</code> family of functions.</p>
<section id="reference-categories" class="level2"><h2 class="anchored" data-anchor-id="reference-categories">Reference categories</h2>
<p>When estimating models with factor regressors, <code>R</code> will typically omit the reference category. We can include an empty row for the reference level automatically by using the <code>include_reference</code> argument. This argument is supplied by the <code>parameters</code> package, which <code>modelsummary</code> uses behind the scenes to extract model estimates. We can supply it directly to <code><a href="https://modelsummary.com/man/modelsummary.html">modelsummary()</a></code>, which will then pass the argument forward automatically:</p>
<div class="cell">
<div class="sourceCode" id="cb76"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">tmp</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/transform.html">transform</a></span><span class="op">(</span><span class="va">mtcars</span>, cyl <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">cyl</span>, <span class="va">tmp</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, include_reference <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_6jtrtk6120zn9r2m8xo7(i, j, css_id) {
          var table = document.getElementById("tinytable_6jtrtk6120zn9r2m8xo7");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_6jtrtk6120zn9r2m8xo7(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_6jtrtk6120zn9r2m8xo7");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '15', j: 1 },  ], css_id: 'tinytable_css_7fftkj3frzry4r6isnc6',}, 
          { positions: [ { i: '7', j: 1 },  ], css_id: 'tinytable_css_i0wpgc2xdn6gelnvmpmj',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '11', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 },  ], css_id: 'tinytable_css_ohfytfo3z39fwuzdjrsw',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_ycuuiwvqb63ah6hiytgp',}, 
          { positions: [ { i: '15', j: 0 },  ], css_id: 'tinytable_css_964xf62qtilc8h8ocafk',}, 
          { positions: [ { i: '7', j: 0 },  ], css_id: 'tinytable_css_jr8h0bdnjzbeq7yh2en1',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '11', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 },  ], css_id: 'tinytable_css_xxhtad617cckwfhebrfs',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_fslcor5urq6g9ecwwclk',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_6jtrtk6120zn9r2m8xo7(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_7fftkj3frzry4r6isnc6, .table th.tinytable_css_7fftkj3frzry4r6isnc6 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_i0wpgc2xdn6gelnvmpmj, .table th.tinytable_css_i0wpgc2xdn6gelnvmpmj { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_ohfytfo3z39fwuzdjrsw, .table th.tinytable_css_ohfytfo3z39fwuzdjrsw { text-align: center; }
      .table td.tinytable_css_ycuuiwvqb63ah6hiytgp, .table th.tinytable_css_ycuuiwvqb63ah6hiytgp { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_964xf62qtilc8h8ocafk, .table th.tinytable_css_964xf62qtilc8h8ocafk { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_jr8h0bdnjzbeq7yh2en1, .table th.tinytable_css_jr8h0bdnjzbeq7yh2en1 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_xxhtad617cckwfhebrfs, .table th.tinytable_css_xxhtad617cckwfhebrfs { text-align: left; }
      .table td.tinytable_css_fslcor5urq6g9ecwwclk, .table th.tinytable_css_fslcor5urq6g9ecwwclk { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_6jtrtk6120zn9r2m8xo7" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">26.664</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.972)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">cyl4</td>
                  <td data-row="3" data-col="1">-</td>
                </tr>
<tr>
<td data-row="4" data-col="0">cyl6</td>
                  <td data-row="4" data-col="1">-6.921</td>
                </tr>
<tr>
<td data-row="5" data-col="0"></td>
                  <td data-row="5" data-col="1">(1.558)</td>
                </tr>
<tr>
<td data-row="6" data-col="0">cyl8</td>
                  <td data-row="6" data-col="1">-11.564</td>
                </tr>
<tr>
<td data-row="7" data-col="0"></td>
                  <td data-row="7" data-col="1">(1.299)</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Num.Obs.</td>
                  <td data-row="8" data-col="1">32</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2</td>
                  <td data-row="9" data-col="1">0.732</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2 Adj.</td>
                  <td data-row="10" data-col="1">0.714</td>
                </tr>
<tr>
<td data-row="11" data-col="0">AIC</td>
                  <td data-row="11" data-col="1">170.6</td>
                </tr>
<tr>
<td data-row="12" data-col="0">BIC</td>
                  <td data-row="12" data-col="1">176.4</td>
                </tr>
<tr>
<td data-row="13" data-col="0">Log.Lik.</td>
                  <td data-row="13" data-col="1">-81.282</td>
                </tr>
<tr>
<td data-row="14" data-col="0">F</td>
                  <td data-row="14" data-col="1">39.698</td>
                </tr>
<tr>
<td data-row="15" data-col="0">RMSE</td>
                  <td data-row="15" data-col="1">3.07</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="standardization" class="level2"><h2 class="anchored" data-anchor-id="standardization">Standardization</h2>
<p>In some cases, it is useful to standardize coefficients before reporting them. <code>modelsummary</code> extracts coefficients from model objects using the <code>parameters</code> package, and that package offers several options for standardization: https://easystats.github.io/parameters/reference/model_parameters.default.html</p>
<p>We can pass the <code>standardize</code> argument directly to <code>modelsummary</code> or <code>modelplot</code>, and that argument will be forwarded to <code>parameters</code>. For example to refit the model on standardized data and plot the results, we can do:</p>
<div class="cell">
<div class="sourceCode" id="cb77"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">am</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelplot.html">modelplot</a></span><span class="op">(</span><span class="va">mod</span>, standardize <span class="op">=</span> <span class="st">"refit"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure"><p><img src="modelsummary_files/figure-html/unnamed-chunk-59-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Compare to the unstandardized plot:</p>
<div class="cell">
<div class="sourceCode" id="cb78"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelplot.html">modelplot</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div>
<figure class="figure"><p><img src="modelsummary_files/figure-html/unnamed-chunk-60-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
</section></section><section id="math" class="level1"><h1>Math</h1>
<p>We can display math in tables by enclosing math expressions in dollars signs and setting the argument <code>escape=FALSE</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb79"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">res</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">wt</span> <span class="op">~</span> <span class="va">mpg</span> <span class="op">+</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span></span>
<span>  <span class="va">res</span>,</span>
<span>  escape <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  title <span class="op">=</span> <span class="st">"Another math expression: $\\sum_{i=1}^n x^-i$"</span>,</span>
<span>  coef_rename <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"mpg"</span> <span class="op">=</span> <span class="st">"$\\beta_1$"</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_fvgntc556omyqkuw5gtn(i, j, css_id) {
          var table = document.getElementById("tinytable_fvgntc556omyqkuw5gtn");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_fvgntc556omyqkuw5gtn(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_fvgntc556omyqkuw5gtn");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '14', j: 1 },  ], css_id: 'tinytable_css_dn6cd7jwn8su6sv7128u',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_a43w8bfwwwbdauw1szc9',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 },  ], css_id: 'tinytable_css_a7h9hh9umhu6d8hc94f2',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_kg13suctv1oznhizzv7y',}, 
          { positions: [ { i: '14', j: 0 },  ], css_id: 'tinytable_css_24zj0ptc4dlsc3x4f5br',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_ucox4xg9grrf9if6au6j',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_2ymmkyn6coaq1kh3hw22',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_r8y7sswoqke4l5qc59v4',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_fvgntc556omyqkuw5gtn(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_dn6cd7jwn8su6sv7128u, .table th.tinytable_css_dn6cd7jwn8su6sv7128u { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_a43w8bfwwwbdauw1szc9, .table th.tinytable_css_a43w8bfwwwbdauw1szc9 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_a7h9hh9umhu6d8hc94f2, .table th.tinytable_css_a7h9hh9umhu6d8hc94f2 { text-align: center; }
      .table td.tinytable_css_kg13suctv1oznhizzv7y, .table th.tinytable_css_kg13suctv1oznhizzv7y { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_24zj0ptc4dlsc3x4f5br, .table th.tinytable_css_24zj0ptc4dlsc3x4f5br { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ucox4xg9grrf9if6au6j, .table th.tinytable_css_ucox4xg9grrf9if6au6j { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_2ymmkyn6coaq1kh3hw22, .table th.tinytable_css_2ymmkyn6coaq1kh3hw22 { text-align: left; }
      .table td.tinytable_css_r8y7sswoqke4l5qc59v4, .table th.tinytable_css_r8y7sswoqke4l5qc59v4 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_fvgntc556omyqkuw5gtn" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead>
</thead><caption>Another math expression: $\sum_{i=1}^n x^-i$</caption>
              <tbody><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr>

</tbody><tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">7.035</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.597)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">$\beta_1$</td>
                  <td data-row="3" data-col="1">-0.116</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.019)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1">-0.415</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.218)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.780</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.765</td>
                </tr>
<tr>
<td data-row="10" data-col="0">AIC</td>
                  <td data-row="10" data-col="1">47.9</td>
                </tr>
<tr>
<td data-row="11" data-col="0">BIC</td>
                  <td data-row="11" data-col="1">53.8</td>
                </tr>
<tr>
<td data-row="12" data-col="0">Log.Lik.</td>
                  <td data-row="12" data-col="1">-19.951</td>
                </tr>
<tr>
<td data-row="13" data-col="0">F</td>
                  <td data-row="13" data-col="1">51.510</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">0.45</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="themes-and-styles" class="level1"><h1>Themes and styles</h1>
<p>To customize the appearance of tables, <code>modelsummary</code> supports six popular and extremely powerful table-making packages:</p>
<ol type="1">
<li><a href="https://vincentarelbundock.github.io/tinytable/"><code>tinytable</code>: https://vincentarelbundock.github.io/tinytable/</a></li>
<li><a href="https://gt.rstudio.com"><code>gt</code>: https://gt.rstudio.com</a></li>
<li><a href="http://haozhu233.github.io/kableExtra"><code>kableExtra</code>: http://haozhu233.github.io/kableExtra</a></li>
<li><a href="https://hughjonesd.github.io/huxtable/"><code>huxtable</code>: https://hughjonesd.github.io/huxtable/</a></li>
<li><a href="https://davidgohel.github.io/flextable/"><code>flextable</code>: https://davidgohel.github.io/flextable/</a></li>
<li><a href="https://rstudio.github.io/DT"><code>DT</code>: https://rstudio.github.io/DT</a></li>
</ol>
<p>The <a href="https://modelsummary.com/vignettes/appearance.html">“customizing the look of your tables” vignette</a> shows examples for all 4 packages.</p>
</section><section id="supported-models" class="level1"><h1>Supported models</h1>
<p><code>modelsummary</code> automatically supports all the models supported by the <code>tidy</code> function of the <a href="broom.tidymodels.org">broom package</a> or the <code>parameters</code> function of the <a href="https://easystats.github.io/parameters/">parameters package</a>. The list of supported models is rapidly expanding. At the moment, it covers the following model classes:</p>
<div class="cell">
<div class="sourceCode" id="cb80"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/supported_models.html">supported_models</a></span><span class="op">(</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>  [1] "aareg"                    "acf"                      "afex_aov"                 "AKP"                      "anova"                    "Anova.mlm"                "anova.rms"                "aov"                      "aovlist"                  "Arima"                    "asym"                     "averaging"                "bamlss"                   "bayesQR"                  "bcplm"                    "befa"                     "betamfx"                  "betaor"                   "betareg"                  "BFBayesFactor"            "bfsl"                     "BGGM"                     "bifeAPEs"                 "biglm"                    "binDesign"                "binWidth"                 "blavaan"                  "blrm"                     "boot"                     "bootstrap_model"          "bracl"                    "brmsfit"                  "brmultinom"               "btergm"                   "cch"                      "censReg"                  "cgam"                     "character"                "cld"                      "clm"                      "clm2"                     "clmm"                     "clmm2"                    "coeftest"                 "compare.loo"              "comparisons"              "confint.glht"             "confusionMatrix"          "coxme"                    "coxph"                    "cpglmm"                   "crr"                      "cv.glmnet"                "data.frame"               "dbscan"                   "default"                  "deltaMethod"              "density"                  "dep.effect"               "DirichletRegModel"        "dist"                     "draws"                    "drc"                      "durbinWatsonTest"         "emm_list"                 "emmeans"                  "emmeans_summary"          "emmGrid"                  "epi.2by2"                 "ergm"                     "fa"                       "fa.ci"                    "factanal"                 "FAMD"                     "feglm"                    "felm"                     "fitdistr"                 "fixest"                   "fixest_multi"             "flac"                     "flic"                     "ftable"                   "gam"                      "Gam"                      "gamlss"                   "gamm"                     "garch"                    "geeglm"                   "glht"                     "glimML"                   "glm"                      "glmm"                     "glmmTMB"                  "glmnet"                   "glmrob"                   "glmRob"                   "glmx"                     "gmm"                      "hclust"                   "hdbscan"                  "hglm"                     "hkmeans"                  "HLfit"                    "htest"                    "hurdle"                   "hypotheses"               "irlba"                    "item_omega"               "ivFixed"                  "ivprobit"                 "ivreg"                    "kappa"                    "kde"                      "Kendall"                  "kmeans"                   "lavaan"                   "leveneTest"               "Line"                     "Lines"                    "list"                     "lm"                       "lm_robust"                "lm.beta"                  "lme"                      "lmodel2"                  "lmrob"                    "lmRob"                    "logical"                  "logistf"                  "logitmfx"                 "logitor"                  "lqm"                      "lqmm"                     "lsmobj"                   "manova"                   "maov"                     "map"                      "marginaleffects"          "marginalmeans"            "margins"                  "maxim"                    "maxLik"                   "mblogit"                  "Mclust"                   "mcmc"                     "mcmc.list"                "MCMCglmm"                 "mcp1"                     "mcp2"                     "med1way"                  "mediate"                  "merMod"                   "merModList"               "meta_bma"                 "meta_fixed"               "meta_random"              "metaplus"                 "mfx"                      "mhurdle"                  "mipo"                     "mira"                     "mixed"                    "MixMod"                   "mixor"                    "mjoint"                   "mle"                      "mle2"                     "mlm"                      "mlogit"                   "mmrm"                     "mmrm_fit"                 "mmrm_tmb"                 "model_fit"                "model_parameters"         "muhaz"                    "multinom"                 "multinom_weightit"        "mvord"                    "negbin"                   "negbinirr"                "negbinmfx"                "nestedLogit"              "nlrq"                     "nls"                      "NULL"                     "numeric"                  "omega"                    "onesampb"                 "optim"                    "ordinal_weightit"         "osrt"                     "pairwise.htest"           "pam"                      "parameters_efa"           "parameters_pca"           "pb2"                      "PCA"                      "pgmm"                     "plm"                      "PMCMR"                    "poissonirr"               "poissonmfx"               "poLCA"                    "polr"                     "Polygon"                  "Polygons"                 "power.htest"              "prcomp"                   "predictions"              "principal"                "probitmfx"                "pvclust"                  "pyears"                   "rcorr"                    "ref.grid"                 "regsubsets"               "ridgelm"                  "rlm"                      "rlmerMod"                 "rma"                      "robtab"                   "roc"                      "rq"                       "rqs"                      "rqss"                     "sarlm"                    "Sarlm"                    "scam"                     "selection"                "sem"                      "SemiParBIV"               "seqanova.svyglm"          "slopes"                   "SpatialLinesDataFrame"    "SpatialPolygons"          "SpatialPolygonsDataFrame" "spec"                     "speedglm"                 "speedlm"                  "stanfit"                  "stanmvreg"                "stanreg"                  "summary_emm"              "summary.glht"             "summary.lm"               "summary.plm"              "summaryDefault"           "survdiff"                 "survexp"                  "survfit"                  "survreg"                  "svd"                      "svy2lme"                  "svyglm"                   "svyolr"                   "svytable"                 "systemfit"                "t1way"                    "table"                    "tobit"                    "trendPMCMR"               "trimcibt"                 "ts"                       "TukeyHSD"                 "varest"                   "vgam"                     "wbgee"                    "wbm"                      "wmcpAKP"                  "xyz"                      "yuen"                     "zcpglm"                   "zerocount"                "zeroinfl"                 "zoo"                     </code></pre>
</div>
</div>
<p>To see if a given model is supported, you can fit it, and then call this function:</p>
<div class="cell">
<div class="sourceCode" id="cb82"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/get_estimates.html">get_estimates</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>If this function does not return a valid output, you can easily (really!!) add your own support. <a href="https://modelsummary.com/vignettes/modelsummary_extension.html">See the “Extension and Customization” vignette</a>. If you do this, you may consider opening an issue on the Github website of the <code>broom</code> package: https://github.com/tidymodels/broom/issues</p>
</section><section id="rmarkdown-quarto-org-mode" class="level1"><h1>Rmarkdown, Quarto, Org-Mode</h1>
<section id="rmarkdown" class="level2"><h2 class="anchored" data-anchor-id="rmarkdown">Rmarkdown</h2>
<p>You can use <code>modelsummary</code> to insert tables into dynamic documents with <code>knitr</code> or <code>Rmarkdown</code>. This minimal .Rmd file can produce tables in PDF, HTML, or RTF documents:</p>
<ul>
<li><a href="https://github.com/vincentarelbundock/modelsummary/blob/master/examples/minimal.Rmd">minimal.Rmd</a></li>
</ul>
<p>This .Rmd file shows illustrates how to use table numbering and cross-references to produce PDF documents using <code>bookdown</code>:</p>
<ul>
<li><a href="https://github.com/vincentarelbundock/modelsummary/blob/master/examples/cross_references.Rmd">cross_references.Rmd</a></li>
</ul>
<p>This .Rmd file shows how to customize tables in PDF and HTML files using <code>gt</code> and <code>kableExtra</code> functions:</p>
<ul>
<li><a href="https://github.com/vincentarelbundock/modelsummary/blob/master/examples/appearance.Rmd">appearance.Rmd</a></li>
</ul></section><section id="quarto" class="level2"><h2 class="anchored" data-anchor-id="quarto">Quarto</h2>
<p><a href="https://quarto.org/">Quarto is an open source publishing system</a> built on top of Pandoc. It was designed as a “successor” to Rmarkdown, and includes useful features for technical writing, such as built-in support for cross-references. <code>modelsummary</code> works automatically with Quarto. This is a minimal document with cross-references which should render automatically to PDF, HTML, and more:</p>
<div class="sourceCode" id="cb83"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb83-1"><a href="#cb83-1" aria-hidden="true" tabindex="-1"></a><span class="sc">---</span></span>
<span id="cb83-2"><a href="#cb83-2" aria-hidden="true" tabindex="-1"></a>format<span class="sc">:</span> pdf</span>
<span id="cb83-3"><a href="#cb83-3" aria-hidden="true" tabindex="-1"></a>title<span class="sc">:</span> Example</span>
<span id="cb83-4"><a href="#cb83-4" aria-hidden="true" tabindex="-1"></a><span class="sc">---</span></span>
<span id="cb83-5"><a href="#cb83-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-6"><a href="#cb83-6" aria-hidden="true" tabindex="-1"></a><span class="er">@</span>tbl<span class="sc">-</span>mtcars shows that cars with high horse power get low miles per gallon.</span>
<span id="cb83-7"><a href="#cb83-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-8"><a href="#cb83-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-9"><a href="#cb83-9" aria-hidden="true" tabindex="-1"></a><span class="sc">:::</span> {<span class="co">#tbl-mtcars .cell tbl-cap='Horse Powers vs. Miles per Gallon'}</span></span>
<span id="cb83-10"><a href="#cb83-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-11"><a href="#cb83-11" aria-hidden="true" tabindex="-1"></a><span class="st">```</span><span class="at">{.r .cell-code}</span></span>
<span id="cb83-12"><a href="#cb83-12" aria-hidden="true" tabindex="-1"></a><span class="at">library(modelsummary)</span></span>
<span id="cb83-13"><a href="#cb83-13" aria-hidden="true" tabindex="-1"></a><span class="at">mod &lt;- lm(mpg ~ hp, mtcars)</span></span>
<span id="cb83-14"><a href="#cb83-14" aria-hidden="true" tabindex="-1"></a><span class="at">modelsummary(mod)</span></span>
<span id="cb83-15"><a href="#cb83-15" aria-hidden="true" tabindex="-1"></a><span class="st">```</span></span>
<span id="cb83-16"><a href="#cb83-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-17"><a href="#cb83-17" aria-hidden="true" tabindex="-1"></a><span class="sc">:::</span> {.cell<span class="sc">-</span>output<span class="sc">-</span>display}</span>
<span id="cb83-18"><a href="#cb83-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-19"><a href="#cb83-19" aria-hidden="true" tabindex="-1"></a><span class="st">```</span><span class="at">{=html}</span></span>
<span id="cb83-20"><a href="#cb83-20" aria-hidden="true" tabindex="-1"></a><span class="at">&lt;!-- preamble start --&gt;</span></span>
<span id="cb83-21"><a href="#cb83-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-22"><a href="#cb83-22" aria-hidden="true" tabindex="-1"></a><span class="at">    &lt;script&gt;</span></span>
<span id="cb83-23"><a href="#cb83-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-24"><a href="#cb83-24" aria-hidden="true" tabindex="-1"></a><span class="at">      function styleCell_46e5wi9jistrpra8ples(i, j, css_id) {</span></span>
<span id="cb83-25"><a href="#cb83-25" aria-hidden="true" tabindex="-1"></a><span class="at">          var table = document.getElementById("tinytable_46e5wi9jistrpra8ples");</span></span>
<span id="cb83-26"><a href="#cb83-26" aria-hidden="true" tabindex="-1"></a><span class="at">          var cell = table.querySelector(</span><span class="st">`</span>[data<span class="sc">-</span>row<span class="ot">=</span><span class="st">"${i}"</span>][data<span class="sc">-</span>col<span class="ot">=</span><span class="st">"${j}"</span>]<span class="st">`</span><span class="at">);</span></span>
<span id="cb83-27"><a href="#cb83-27" aria-hidden="true" tabindex="-1"></a><span class="at">          if (cell) {</span></span>
<span id="cb83-28"><a href="#cb83-28" aria-hidden="true" tabindex="-1"></a><span class="at">              console.log(</span><span class="st">`</span>Styling cell <span class="fu">at</span> (<span class="sc">$</span>{i}, <span class="sc">$</span>{j}) with class <span class="sc">$</span>{css_id}<span class="st">`</span><span class="at">);</span></span>
<span id="cb83-29"><a href="#cb83-29" aria-hidden="true" tabindex="-1"></a><span class="at">              cell.classList.add(css_id);</span></span>
<span id="cb83-30"><a href="#cb83-30" aria-hidden="true" tabindex="-1"></a><span class="at">          } else {</span></span>
<span id="cb83-31"><a href="#cb83-31" aria-hidden="true" tabindex="-1"></a><span class="at">              console.warn(</span><span class="st">`</span>Cell <span class="fu">at</span> (<span class="sc">$</span>{i}, <span class="sc">$</span>{j}) not found.<span class="st">`</span><span class="at">);</span></span>
<span id="cb83-32"><a href="#cb83-32" aria-hidden="true" tabindex="-1"></a><span class="at">          }</span></span>
<span id="cb83-33"><a href="#cb83-33" aria-hidden="true" tabindex="-1"></a><span class="at">      }</span></span>
<span id="cb83-34"><a href="#cb83-34" aria-hidden="true" tabindex="-1"></a><span class="at">      function spanCell_46e5wi9jistrpra8ples(i, j, rowspan, colspan) {</span></span>
<span id="cb83-35"><a href="#cb83-35" aria-hidden="true" tabindex="-1"></a><span class="at">        var table = document.getElementById("tinytable_46e5wi9jistrpra8ples");</span></span>
<span id="cb83-36"><a href="#cb83-36" aria-hidden="true" tabindex="-1"></a><span class="at">        const targetCell = table.querySelector(</span><span class="st">`</span>[data<span class="sc">-</span>row<span class="ot">=</span><span class="st">"${i}"</span>][data<span class="sc">-</span>col<span class="ot">=</span><span class="st">"${j}"</span>]<span class="st">`</span><span class="at">);</span></span>
<span id="cb83-37"><a href="#cb83-37" aria-hidden="true" tabindex="-1"></a><span class="at">        if (!targetCell) {</span></span>
<span id="cb83-38"><a href="#cb83-38" aria-hidden="true" tabindex="-1"></a><span class="at">          console.warn(</span><span class="st">`</span>Cell <span class="fu">at</span> (<span class="sc">$</span>{i}, <span class="sc">$</span>{j}) not found.<span class="st">`</span><span class="at">);</span></span>
<span id="cb83-39"><a href="#cb83-39" aria-hidden="true" tabindex="-1"></a><span class="at">        }</span></span>
<span id="cb83-40"><a href="#cb83-40" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-41"><a href="#cb83-41" aria-hidden="true" tabindex="-1"></a><span class="at">        // Get all cells that need to be removed</span></span>
<span id="cb83-42"><a href="#cb83-42" aria-hidden="true" tabindex="-1"></a><span class="at">        const cellsToRemove = [];</span></span>
<span id="cb83-43"><a href="#cb83-43" aria-hidden="true" tabindex="-1"></a><span class="at">        for (let r = 0; r &lt; rowspan; r++) {</span></span>
<span id="cb83-44"><a href="#cb83-44" aria-hidden="true" tabindex="-1"></a><span class="at">          for (let c = 0; c &lt; colspan; c++) {</span></span>
<span id="cb83-45"><a href="#cb83-45" aria-hidden="true" tabindex="-1"></a><span class="at">            if (r === 0 &amp;&amp; c === 0) continue; // Skip the target cell</span></span>
<span id="cb83-46"><a href="#cb83-46" aria-hidden="true" tabindex="-1"></a><span class="at">            const cell = table.querySelector(</span><span class="st">`</span>[data<span class="sc">-</span>row<span class="ot">=</span><span class="st">"${i + r}"</span>][data<span class="sc">-</span>col<span class="ot">=</span><span class="st">"${j + c}"</span>]<span class="st">`</span><span class="at">);</span></span>
<span id="cb83-47"><a href="#cb83-47" aria-hidden="true" tabindex="-1"></a><span class="at">            if (cell) {</span></span>
<span id="cb83-48"><a href="#cb83-48" aria-hidden="true" tabindex="-1"></a><span class="at">              cellsToRemove.push(cell);</span></span>
<span id="cb83-49"><a href="#cb83-49" aria-hidden="true" tabindex="-1"></a><span class="at">            }</span></span>
<span id="cb83-50"><a href="#cb83-50" aria-hidden="true" tabindex="-1"></a><span class="at">          }</span></span>
<span id="cb83-51"><a href="#cb83-51" aria-hidden="true" tabindex="-1"></a><span class="at">        }</span></span>
<span id="cb83-52"><a href="#cb83-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-53"><a href="#cb83-53" aria-hidden="true" tabindex="-1"></a><span class="at">        // Remove all cells</span></span>
<span id="cb83-54"><a href="#cb83-54" aria-hidden="true" tabindex="-1"></a><span class="at">        cellsToRemove.forEach(cell =&gt; cell.remove());</span></span>
<span id="cb83-55"><a href="#cb83-55" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-56"><a href="#cb83-56" aria-hidden="true" tabindex="-1"></a><span class="at">        // Set rowspan and colspan of the target cell if it exists</span></span>
<span id="cb83-57"><a href="#cb83-57" aria-hidden="true" tabindex="-1"></a><span class="at">        if (targetCell) {</span></span>
<span id="cb83-58"><a href="#cb83-58" aria-hidden="true" tabindex="-1"></a><span class="at">          targetCell.rowSpan = rowspan;</span></span>
<span id="cb83-59"><a href="#cb83-59" aria-hidden="true" tabindex="-1"></a><span class="at">          targetCell.colSpan = colspan;</span></span>
<span id="cb83-60"><a href="#cb83-60" aria-hidden="true" tabindex="-1"></a><span class="at">        }</span></span>
<span id="cb83-61"><a href="#cb83-61" aria-hidden="true" tabindex="-1"></a><span class="at">      }</span></span>
<span id="cb83-62"><a href="#cb83-62" aria-hidden="true" tabindex="-1"></a><span class="at">      // tinytable span after</span></span>
<span id="cb83-63"><a href="#cb83-63" aria-hidden="true" tabindex="-1"></a><span class="at">      window.addEventListener('load', function () {</span></span>
<span id="cb83-64"><a href="#cb83-64" aria-hidden="true" tabindex="-1"></a><span class="at">          var cellsToStyle = [</span></span>
<span id="cb83-65"><a href="#cb83-65" aria-hidden="true" tabindex="-1"></a><span class="at">            // tinytable style arrays after</span></span>
<span id="cb83-66"><a href="#cb83-66" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '12', j: 1 },  ], css_id: 'tinytable_css_axzx5unpyjd0b8thmxrd',}, </span></span>
<span id="cb83-67"><a href="#cb83-67" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '4', j: 1 },  ], css_id: 'tinytable_css_ia1vj3yri30rv4xjzs45',}, </span></span>
<span id="cb83-68"><a href="#cb83-68" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '8', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 },  ], css_id: 'tinytable_css_v66bxsl3g6x7yumpt6rm',}, </span></span>
<span id="cb83-69"><a href="#cb83-69" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_yaoxmloin0g7fkx9nju6',}, </span></span>
<span id="cb83-70"><a href="#cb83-70" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_9kg75n1zvjpgpqv37yay',}, </span></span>
<span id="cb83-71"><a href="#cb83-71" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_xogawgsl99lolf601ss1',}, </span></span>
<span id="cb83-72"><a href="#cb83-72" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 },  ], css_id: 'tinytable_css_l73xbvvx17mpj6oea85j',}, </span></span>
<span id="cb83-73"><a href="#cb83-73" aria-hidden="true" tabindex="-1"></a><span class="at">          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_c0raovjw1mgcyzrzlph4',}, </span></span>
<span id="cb83-74"><a href="#cb83-74" aria-hidden="true" tabindex="-1"></a><span class="at">          ];</span></span>
<span id="cb83-75"><a href="#cb83-75" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-76"><a href="#cb83-76" aria-hidden="true" tabindex="-1"></a><span class="at">          // Loop over the arrays to style the cells</span></span>
<span id="cb83-77"><a href="#cb83-77" aria-hidden="true" tabindex="-1"></a><span class="at">          cellsToStyle.forEach(function (group) {</span></span>
<span id="cb83-78"><a href="#cb83-78" aria-hidden="true" tabindex="-1"></a><span class="at">              group.positions.forEach(function (cell) {</span></span>
<span id="cb83-79"><a href="#cb83-79" aria-hidden="true" tabindex="-1"></a><span class="at">                  styleCell_46e5wi9jistrpra8ples(cell.i, cell.j, group.css_id);</span></span>
<span id="cb83-80"><a href="#cb83-80" aria-hidden="true" tabindex="-1"></a><span class="at">              });</span></span>
<span id="cb83-81"><a href="#cb83-81" aria-hidden="true" tabindex="-1"></a><span class="at">          });</span></span>
<span id="cb83-82"><a href="#cb83-82" aria-hidden="true" tabindex="-1"></a><span class="at">      });</span></span>
<span id="cb83-83"><a href="#cb83-83" aria-hidden="true" tabindex="-1"></a><span class="at">    &lt;/script&gt;</span></span>
<span id="cb83-84"><a href="#cb83-84" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-85"><a href="#cb83-85" aria-hidden="true" tabindex="-1"></a><span class="at">    &lt;style&gt;</span></span>
<span id="cb83-86"><a href="#cb83-86" aria-hidden="true" tabindex="-1"></a><span class="at">      /* tinytable css entries after */</span></span>
<span id="cb83-87"><a href="#cb83-87" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_axzx5unpyjd0b8thmxrd, .table th.tinytable_css_axzx5unpyjd0b8thmxrd { text-align: center; border-bottom: solid #d3d8dc 0.1em; }</span></span>
<span id="cb83-88"><a href="#cb83-88" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_ia1vj3yri30rv4xjzs45, .table th.tinytable_css_ia1vj3yri30rv4xjzs45 { text-align: center; border-bottom: solid black 0.05em; }</span></span>
<span id="cb83-89"><a href="#cb83-89" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_v66bxsl3g6x7yumpt6rm, .table th.tinytable_css_v66bxsl3g6x7yumpt6rm { text-align: center; }</span></span>
<span id="cb83-90"><a href="#cb83-90" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_yaoxmloin0g7fkx9nju6, .table th.tinytable_css_yaoxmloin0g7fkx9nju6 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }</span></span>
<span id="cb83-91"><a href="#cb83-91" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_9kg75n1zvjpgpqv37yay, .table th.tinytable_css_9kg75n1zvjpgpqv37yay { text-align: left; border-bottom: solid #d3d8dc 0.1em; }</span></span>
<span id="cb83-92"><a href="#cb83-92" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_xogawgsl99lolf601ss1, .table th.tinytable_css_xogawgsl99lolf601ss1 { text-align: left; border-bottom: solid black 0.05em; }</span></span>
<span id="cb83-93"><a href="#cb83-93" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_l73xbvvx17mpj6oea85j, .table th.tinytable_css_l73xbvvx17mpj6oea85j { text-align: left; }</span></span>
<span id="cb83-94"><a href="#cb83-94" aria-hidden="true" tabindex="-1"></a><span class="at">      .table td.tinytable_css_c0raovjw1mgcyzrzlph4, .table th.tinytable_css_c0raovjw1mgcyzrzlph4 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }</span></span>
<span id="cb83-95"><a href="#cb83-95" aria-hidden="true" tabindex="-1"></a><span class="at">    &lt;/style&gt;</span></span>
<span id="cb83-96"><a href="#cb83-96" aria-hidden="true" tabindex="-1"></a><span class="at">    &lt;div class="container"&gt;</span></span>
<span id="cb83-97"><a href="#cb83-97" aria-hidden="true" tabindex="-1"></a><span class="at">      &lt;table class="table table-borderless" id="tinytable_46e5wi9jistrpra8ples" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing='true'&gt;</span></span>
<span id="cb83-98"><a href="#cb83-98" aria-hidden="true" tabindex="-1"></a><span class="at">        &lt;thead&gt;</span></span>
<span id="cb83-99"><a href="#cb83-99" aria-hidden="true" tabindex="-1"></a><span class="at">        </span></span>
<span id="cb83-100"><a href="#cb83-100" aria-hidden="true" tabindex="-1"></a><span class="at">              &lt;tr&gt;</span></span>
<span id="cb83-101"><a href="#cb83-101" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;th scope="col" data-row="0" data-col="0"&gt; &lt;/th&gt;</span></span>
<span id="cb83-102"><a href="#cb83-102" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;th scope="col" data-row="0" data-col="1"&gt;(1)&lt;/th&gt;</span></span>
<span id="cb83-103"><a href="#cb83-103" aria-hidden="true" tabindex="-1"></a><span class="at">              &lt;/tr&gt;</span></span>
<span id="cb83-104"><a href="#cb83-104" aria-hidden="true" tabindex="-1"></a><span class="at">        &lt;/thead&gt;</span></span>
<span id="cb83-105"><a href="#cb83-105" aria-hidden="true" tabindex="-1"></a><span class="at">        </span></span>
<span id="cb83-106"><a href="#cb83-106" aria-hidden="true" tabindex="-1"></a><span class="at">        &lt;tbody&gt;</span></span>
<span id="cb83-107"><a href="#cb83-107" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-108"><a href="#cb83-108" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="1" data-col="0"&gt;(Intercept)&lt;/td&gt;</span></span>
<span id="cb83-109"><a href="#cb83-109" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="1" data-col="1"&gt;30.099&lt;/td&gt;</span></span>
<span id="cb83-110"><a href="#cb83-110" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-111"><a href="#cb83-111" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-112"><a href="#cb83-112" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="2" data-col="0"&gt;&lt;/td&gt;</span></span>
<span id="cb83-113"><a href="#cb83-113" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="2" data-col="1"&gt;(1.634)&lt;/td&gt;</span></span>
<span id="cb83-114"><a href="#cb83-114" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-115"><a href="#cb83-115" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-116"><a href="#cb83-116" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="3" data-col="0"&gt;hp&lt;/td&gt;</span></span>
<span id="cb83-117"><a href="#cb83-117" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="3" data-col="1"&gt;-0.068&lt;/td&gt;</span></span>
<span id="cb83-118"><a href="#cb83-118" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-119"><a href="#cb83-119" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-120"><a href="#cb83-120" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="4" data-col="0"&gt;&lt;/td&gt;</span></span>
<span id="cb83-121"><a href="#cb83-121" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="4" data-col="1"&gt;(0.010)&lt;/td&gt;</span></span>
<span id="cb83-122"><a href="#cb83-122" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-123"><a href="#cb83-123" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-124"><a href="#cb83-124" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="5" data-col="0"&gt;Num.Obs.&lt;/td&gt;</span></span>
<span id="cb83-125"><a href="#cb83-125" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="5" data-col="1"&gt;32&lt;/td&gt;</span></span>
<span id="cb83-126"><a href="#cb83-126" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-127"><a href="#cb83-127" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-128"><a href="#cb83-128" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="6" data-col="0"&gt;R2&lt;/td&gt;</span></span>
<span id="cb83-129"><a href="#cb83-129" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="6" data-col="1"&gt;0.602&lt;/td&gt;</span></span>
<span id="cb83-130"><a href="#cb83-130" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-131"><a href="#cb83-131" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-132"><a href="#cb83-132" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="7" data-col="0"&gt;R2 Adj.&lt;/td&gt;</span></span>
<span id="cb83-133"><a href="#cb83-133" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="7" data-col="1"&gt;0.589&lt;/td&gt;</span></span>
<span id="cb83-134"><a href="#cb83-134" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-135"><a href="#cb83-135" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-136"><a href="#cb83-136" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="8" data-col="0"&gt;AIC&lt;/td&gt;</span></span>
<span id="cb83-137"><a href="#cb83-137" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="8" data-col="1"&gt;181.2&lt;/td&gt;</span></span>
<span id="cb83-138"><a href="#cb83-138" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-139"><a href="#cb83-139" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-140"><a href="#cb83-140" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="9" data-col="0"&gt;BIC&lt;/td&gt;</span></span>
<span id="cb83-141"><a href="#cb83-141" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="9" data-col="1"&gt;185.6&lt;/td&gt;</span></span>
<span id="cb83-142"><a href="#cb83-142" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-143"><a href="#cb83-143" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-144"><a href="#cb83-144" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="10" data-col="0"&gt;Log.Lik.&lt;/td&gt;</span></span>
<span id="cb83-145"><a href="#cb83-145" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="10" data-col="1"&gt;-87.619&lt;/td&gt;</span></span>
<span id="cb83-146"><a href="#cb83-146" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-147"><a href="#cb83-147" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-148"><a href="#cb83-148" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="11" data-col="0"&gt;F&lt;/td&gt;</span></span>
<span id="cb83-149"><a href="#cb83-149" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="11" data-col="1"&gt;45.460&lt;/td&gt;</span></span>
<span id="cb83-150"><a href="#cb83-150" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-151"><a href="#cb83-151" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;tr&gt;</span></span>
<span id="cb83-152"><a href="#cb83-152" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="12" data-col="0"&gt;RMSE&lt;/td&gt;</span></span>
<span id="cb83-153"><a href="#cb83-153" aria-hidden="true" tabindex="-1"></a><span class="at">                  &lt;td data-row="12" data-col="1"&gt;3.74&lt;/td&gt;</span></span>
<span id="cb83-154"><a href="#cb83-154" aria-hidden="true" tabindex="-1"></a><span class="at">                &lt;/tr&gt;</span></span>
<span id="cb83-155"><a href="#cb83-155" aria-hidden="true" tabindex="-1"></a><span class="at">        &lt;/tbody&gt;</span></span>
<span id="cb83-156"><a href="#cb83-156" aria-hidden="true" tabindex="-1"></a><span class="at">      &lt;/table&gt;</span></span>
<span id="cb83-157"><a href="#cb83-157" aria-hidden="true" tabindex="-1"></a><span class="at">    &lt;/div&gt;</span></span>
<span id="cb83-158"><a href="#cb83-158" aria-hidden="true" tabindex="-1"></a><span class="at">&lt;!-- hack to avoid NA insertion in last line --&gt;</span></span>
<span id="cb83-159"><a href="#cb83-159" aria-hidden="true" tabindex="-1"></a><span class="st">```</span></span>
<span id="cb83-160"><a href="#cb83-160" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-161"><a href="#cb83-161" aria-hidden="true" tabindex="-1"></a><span class="sc">:::</span></span>
<span id="cb83-162"><a href="#cb83-162" aria-hidden="true" tabindex="-1"></a><span class="er">:::</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</section><section id="emacs-org-mode" class="level2"><h2 class="anchored" data-anchor-id="emacs-org-mode">Emacs Org-Mode</h2>
<p>You can use <code>modelsummary</code> to insert tables into Emacs Org-Mode documents, which can be exported to a variety of formats, including HTML and PDF (via LaTeX). As with anything Emacs-related, there are many ways to achieve the outcomes you want. Here is one example of an Org-Mode document which can automatically export tables to HTML and PDF without manual tweaks:</p>
<pre><code>#+PROPERTY: header-args:R :var orgbackend=(prin1-to-string org-export-current-backend)
#+MACRO: Rtable (eval (concat "#+header: :results output " (prin1-to-string org-export-current-backend)))

{{{Rtable}}}
#+BEGIN_SRC R :exports both
library(modelsummary)
options(modelsummary_factory_default = orgbackend)

mod = lm(hp ~ mpg, data = mtcars)

modelsummary(mod)
#+END_SRC</code></pre>
<p>The first line tells Org-mode to assign a variable called <code>orgbackend</code>. This variable will be accessible by the <code>R</code> session, and will be equal to “html” or “latex”, depending on the export format.</p>
<p>The second line creates an Org macro which we will use to automatically add useful information to the header of source blocks. For instance, when we export to HTML, the macro will expand to <code>:results output html</code>. This tells Org-Mode to insert the last printed output from the <code>R</code> session, and to treat it as raw HTML.</p>
<p>The <code>{{Rtable}}</code> call expands the macro to add information to the header of the block that follows.</p>
<p><code>#+BEGIN_SRC R :exports both</code> says that we want to print both the original code and the output (<code>:exports results</code> would omit the code, for example).</p>
<p>Finally, <code>options(modelsummary_factory_default=orgbackend</code> uses the variable we defined to set the default output format. That way, we don’t have to use the <code>output</code> argument every time.</p>
<p>One potentially issue to keep in mind is that the code above extracts the printout from the <code>R</code> console. However, when we customize tables with <code>kableExtra</code> or <code>gt</code> functions, those functions do not always return printed raw HTML or LaTeX code. Sometimes, it can be necessary to add a call to <code>cat</code> at the end of a table customization pipeline. For example:</p>
<pre><code>{{{Rtable}}}
#+BEGIN_SRC R :exports both
library(modelsummary)
library(kableExtra)

mod = lm(hp ~ mpg, data = mtcars)

modelsummary(mod, output = orgbackend) %&gt;%
  row_spec(1, background = "pink") %&gt;%
  cat()
#+END_SRC</code></pre>
</section></section><section id="sec-global-options" class="level1"><h1>Global options</h1>
<p>Users can change the default behavior of <code>modelsummary</code> by setting global options.</p>
<p>Omit the note at the bottom of the table with significance threshold:</p>
<div class="cell">
<div class="sourceCode" id="cb86"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span><span class="st">"modelsummary_stars_note"</span> <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Change the default output format:</p>
<div class="cell">
<div class="sourceCode" id="cb87"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_factory_default <span class="op">=</span> <span class="st">"latex"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_factory_default <span class="op">=</span> <span class="st">"gt"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Change the backend packages that <code>modelsummary</code> uses to create tables in different output formats:</p>
<div class="cell">
<div class="sourceCode" id="cb88"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_factory_html <span class="op">=</span> <span class="st">'kableExtra'</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_factory_latex <span class="op">=</span> <span class="st">'flextable'</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_factory_word <span class="op">=</span> <span class="st">'huxtable'</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_factory_png <span class="op">=</span> <span class="st">'gt'</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Change the packages that <code>modelsummary</code> uses to extract information from models:</p>
<div class="cell">
<div class="sourceCode" id="cb89"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># tidymodels: broom </span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_get <span class="op">=</span> <span class="st">"broom"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># easystats: performance + parameters</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_get <span class="op">=</span> <span class="st">"easystats"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Notice this just sets the first backend that modelsummary will try. In case the backend fails to return a result, modelsummary will try the other one. The final backend that modelsummary used to extract the information from the model is saved in the <code>backend</code> attribute of the object returned by modelsummary.</p>
<p><a href="https://modelsummary.com/vignettes/appearance.html#themes">The <code>appearance</code> vignette</a> shows how to set “themes” for your tables using the <code>modelsummary_theme_gt</code>, <code>modelsummary_theme_kableExtra</code>, <code>modelsummary_theme_flextable</code> and <code>modelsummary_theme_huxtable</code> global options. For example:</p>
<div class="cell">
<div class="sourceCode" id="cb90"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://gt.rstudio.com">gt</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># The ... ellipsis is required!</span></span>
<span><span class="va">custom_theme</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span>, <span class="va">...</span><span class="op">)</span> <span class="op">{</span></span>
<span>    <span class="va">x</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span> <span class="fu">gt</span><span class="fu">::</span><span class="fu"><a href="https://gt.rstudio.com/reference/opt_row_striping.html">opt_row_striping</a></span><span class="op">(</span>row_striping <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span><span class="st">"modelsummary_theme_gt"</span> <span class="op">=</span> <span class="va">custom_theme</span><span class="op">)</span></span>
<span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, output <span class="op">=</span> <span class="st">"gt"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section><section id="case-studies" class="level1"><h1>Case studies</h1>
<section id="collapse-control-variables-into-an-indicator" class="level2"><h2 class="anchored" data-anchor-id="collapse-control-variables-into-an-indicator">Collapse control variables into an indicator</h2>
<p>In some cases, analysts want to display a single checkmark in their table if a full set of control variables is available. This can easily be achieved with the <code>glance_custom</code> mechanism described in detail in <a href="modelsummary_extension.html">the extension vignette.</a> Here is a simple example:</p>
<div class="cell">
<div class="sourceCode" id="cb91"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://modelsummary.com">modelsummary</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/glm.html">glm</a></span><span class="op">(</span><span class="va">am</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span>, data <span class="op">=</span> <span class="va">mtcars</span>, family <span class="op">=</span> <span class="va">binomial</span><span class="op">)</span>,</span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span> <span class="op">+</span> <span class="va">gear</span> <span class="op">+</span> <span class="va">qsec</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="va">glance_custom.lm</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span>, <span class="va">...</span><span class="op">)</span> <span class="op">{</span></span>
<span>  <span class="va">controls</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"gear"</span>, <span class="st">"qsec"</span><span class="op">)</span></span>
<span>  <span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/all.html">all</a></span><span class="op">(</span><span class="va">controls</span> <span class="op"><a href="https://rdrr.io/r/base/match.html">%in%</a></span> <span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/coef.html">coef</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span>
<span>    <span class="va">out</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>Controls <span class="op">=</span> <span class="st">"✓"</span><span class="op">)</span></span>
<span>  <span class="op">}</span> <span class="kw">else</span> <span class="op">{</span></span>
<span>    <span class="va">out</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>Controls <span class="op">=</span> <span class="st">"✗"</span><span class="op">)</span></span>
<span>  <span class="op">}</span></span>
<span>  <span class="kw"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op">(</span><span class="va">out</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="va">glance_custom.glm</span> <span class="op">&lt;-</span> <span class="va">glance_custom.lm</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, <span class="st">"html"</span>, coef_omit <span class="op">=</span> <span class="st">"qsec|gear"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_a6pgc82xog52b5oeso5e(i, j, css_id) {
          var table = document.getElementById("tinytable_a6pgc82xog52b5oeso5e");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_a6pgc82xog52b5oeso5e(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_a6pgc82xog52b5oeso5e");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '17', j: 1 }, { i: '17', j: 2 },  ], css_id: 'tinytable_css_6xpevwx7xizkkzgghk45',}, 
          { positions: [ { i: '8', j: 2 }, { i: '8', j: 1 },  ], css_id: 'tinytable_css_v8hy2gxxei9vriuv8tyc',}, 
          { positions: [ { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '1', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '3', j: 2 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '15', j: 1 }, { i: '16', j: 1 }, { i: '12', j: 2 }, { i: '5', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '16', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '15', j: 2 },  ], css_id: 'tinytable_css_pg3wanmu9p8y4utdscf4',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_84w1q8mvmhthr4cxxqdl',}, 
          { positions: [ { i: '17', j: 0 },  ], css_id: 'tinytable_css_3vhra5g9qb1ikdsrsrhq',}, 
          { positions: [ { i: '8', j: 0 },  ], css_id: 'tinytable_css_uili9f1d1o83tmz99gsl',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '12', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 }, { i: '16', j: 0 }, { i: '13', j: 0 }, { i: '14', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_f1z8pf9h6805857aa1aa',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_hv90oxd8nfxdxh6h0yk1',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_a6pgc82xog52b5oeso5e(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_6xpevwx7xizkkzgghk45, .table th.tinytable_css_6xpevwx7xizkkzgghk45 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_v8hy2gxxei9vriuv8tyc, .table th.tinytable_css_v8hy2gxxei9vriuv8tyc { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_pg3wanmu9p8y4utdscf4, .table th.tinytable_css_pg3wanmu9p8y4utdscf4 { text-align: center; }
      .table td.tinytable_css_84w1q8mvmhthr4cxxqdl, .table th.tinytable_css_84w1q8mvmhthr4cxxqdl { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_3vhra5g9qb1ikdsrsrhq, .table th.tinytable_css_3vhra5g9qb1ikdsrsrhq { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_uili9f1d1o83tmz99gsl, .table th.tinytable_css_uili9f1d1o83tmz99gsl { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_f1z8pf9h6805857aa1aa, .table th.tinytable_css_f1z8pf9h6805857aa1aa { text-align: left; }
      .table td.tinytable_css_hv90oxd8nfxdxh6h0yk1, .table th.tinytable_css_hv90oxd8nfxdxh6h0yk1 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_a6pgc82xog52b5oeso5e" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">−2.029</td>
                  <td data-row="1" data-col="2">33.178</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(1.604)</td>
                  <td data-row="2" data-col="2">(13.713)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">0.038</td>
                  <td data-row="3" data-col="2">−0.057</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.019)</td>
                  <td data-row="4" data-col="2">(0.018)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">factor(cyl)6</td>
                  <td data-row="5" data-col="1">−2.874</td>
                  <td data-row="5" data-col="2">−4.818</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(1.360)</td>
                  <td data-row="6" data-col="2">(1.805)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">factor(cyl)8</td>
                  <td data-row="7" data-col="1">−8.644</td>
                  <td data-row="7" data-col="2">−4.037</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1">(3.423)</td>
                  <td data-row="8" data-col="2">(3.585)</td>
                </tr>
<tr>
<td data-row="9" data-col="0">Num.Obs.</td>
                  <td data-row="9" data-col="1">32</td>
                  <td data-row="9" data-col="2">32</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2</td>
                  <td data-row="10" data-col="1"></td>
                  <td data-row="10" data-col="2">0.812</td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Adj.</td>
                  <td data-row="11" data-col="1"></td>
                  <td data-row="11" data-col="2">0.776</td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">35.2</td>
                  <td data-row="12" data-col="2">165.2</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">41.1</td>
                  <td data-row="13" data-col="2">175.5</td>
                </tr>
<tr>
<td data-row="14" data-col="0">Log.Lik.</td>
                  <td data-row="14" data-col="1">−13.602</td>
                  <td data-row="14" data-col="2">−75.598</td>
                </tr>
<tr>
<td data-row="15" data-col="0">F</td>
                  <td data-row="15" data-col="1">2.514</td>
                  <td data-row="15" data-col="2">22.526</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">0.38</td>
                  <td data-row="16" data-col="2">2.57</td>
                </tr>
<tr>
<td data-row="17" data-col="0">Controls</td>
                  <td data-row="17" data-col="1">✗</td>
                  <td data-row="17" data-col="2">✓</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Return to nomal:</p>
<div class="cell">
<div class="sourceCode" id="cb92"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/rm.html">rm</a></span><span class="op">(</span>list <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"glance_custom.glm"</span>, <span class="st">"glance_custom.lm"</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section><section id="subgroup-estimation-with-nest_by" class="level2"><h2 class="anchored" data-anchor-id="subgroup-estimation-with-nest_by">Subgroup estimation with <code>nest_by</code>
</h2>
<p>Sometimes, it is useful to estimate multiple regression models on subsets of the data. To do this efficiently, we can use the <code>nest_by</code> function from the <code>dplyr</code> package. Then, estimate the models with <code>lm</code>, extract them and name them with <code>pull</code>, and finally summarize them with <code>modelsummary</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb93"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://tidyverse.tidyverse.org">tidyverse</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">mtcars</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/nest_by.html">nest_by</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>models <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span>, <span class="va">data</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/pull.html">pull</a></span><span class="op">(</span><span class="va">models</span>, name <span class="op">=</span> <span class="va">cyl</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="va">modelsummary</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_164b45qbv45getyo1jhd(i, j, css_id) {
          var table = document.getElementById("tinytable_164b45qbv45getyo1jhd");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_164b45qbv45getyo1jhd(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_164b45qbv45getyo1jhd");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '11', j: 2 }, { i: '11', j: 1 }, { i: '11', j: 3 },  ], css_id: 'tinytable_css_wxsz87iefmqsihvj5yb0',}, 
          { positions: [ { i: '4', j: 3 }, { i: '4', j: 2 }, { i: '4', j: 1 },  ], css_id: 'tinytable_css_8e3vjo0fwbj7fwpggz4t',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '3', j: 1 }, { i: '5', j: 2 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '5', j: 3 }, { i: '6', j: 3 }, { i: '6', j: 2 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '3', j: 3 }, { i: '8', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '7', j: 3 }, { i: '9', j: 3 }, { i: '10', j: 3 },  ], css_id: 'tinytable_css_tm5nogng2nfc6xayiv8m',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_72u0qcwnrcwepccv9e9h',}, 
          { positions: [ { i: '11', j: 0 },  ], css_id: 'tinytable_css_c6p12034hgffv5ae6s1w',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_ik112alihitskikomtuv',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 },  ], css_id: 'tinytable_css_wva1xfqzfh9vceumtmnh',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_bf5cqeqbbgqmabskt6hm',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_164b45qbv45getyo1jhd(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_wxsz87iefmqsihvj5yb0, .table th.tinytable_css_wxsz87iefmqsihvj5yb0 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_8e3vjo0fwbj7fwpggz4t, .table th.tinytable_css_8e3vjo0fwbj7fwpggz4t { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_tm5nogng2nfc6xayiv8m, .table th.tinytable_css_tm5nogng2nfc6xayiv8m { text-align: center; }
      .table td.tinytable_css_72u0qcwnrcwepccv9e9h, .table th.tinytable_css_72u0qcwnrcwepccv9e9h { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_c6p12034hgffv5ae6s1w, .table th.tinytable_css_c6p12034hgffv5ae6s1w { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ik112alihitskikomtuv, .table th.tinytable_css_ik112alihitskikomtuv { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_wva1xfqzfh9vceumtmnh, .table th.tinytable_css_wva1xfqzfh9vceumtmnh { text-align: left; }
      .table td.tinytable_css_bf5cqeqbbgqmabskt6hm, .table th.tinytable_css_bf5cqeqbbgqmabskt6hm { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_164b45qbv45getyo1jhd" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">4</th>
                <th scope="col" data-row="0" data-col="2">6</th>
                <th scope="col" data-row="0" data-col="3">8</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">35.983</td>
                  <td data-row="1" data-col="2">20.674</td>
                  <td data-row="1" data-col="3">18.080</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(5.201)</td>
                  <td data-row="2" data-col="2">(3.304)</td>
                  <td data-row="2" data-col="3">(2.988)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">-0.113</td>
                  <td data-row="3" data-col="2">-0.008</td>
                  <td data-row="3" data-col="3">-0.014</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.061)</td>
                  <td data-row="4" data-col="2">(0.027)</td>
                  <td data-row="4" data-col="3">(0.014)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">11</td>
                  <td data-row="5" data-col="2">7</td>
                  <td data-row="5" data-col="3">14</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2</td>
                  <td data-row="6" data-col="1">0.274</td>
                  <td data-row="6" data-col="2">0.016</td>
                  <td data-row="6" data-col="3">0.080</td>
                </tr>
<tr>
<td data-row="7" data-col="0">R2 Adj.</td>
                  <td data-row="7" data-col="1">0.193</td>
                  <td data-row="7" data-col="2">-0.181</td>
                  <td data-row="7" data-col="3">0.004</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">65.8</td>
                  <td data-row="8" data-col="2">29.9</td>
                  <td data-row="8" data-col="3">69.8</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">67.0</td>
                  <td data-row="9" data-col="2">29.7</td>
                  <td data-row="9" data-col="3">71.8</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-29.891</td>
                  <td data-row="10" data-col="2">-11.954</td>
                  <td data-row="10" data-col="3">-31.920</td>
                </tr>
<tr>
<td data-row="11" data-col="0">RMSE</td>
                  <td data-row="11" data-col="1">3.66</td>
                  <td data-row="11" data-col="2">1.33</td>
                  <td data-row="11" data-col="3">2.37</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="bootstrap" class="level2"><h2 class="anchored" data-anchor-id="bootstrap">Bootstrap</h2>
<p>Users often want to use estimates or standard errors that have been obtained using a custom strategy. To achieve this in an automated and replicable way, it can be useful to use the <code>tidy_custom</code> strategy described above in the “Cutomizing Existing Models” section.</p>
<p>For example, we can use the <code>modelr</code> package to draw 500 resamples of a dataset, and compute bootstrap standard errors by taking the standard deviation of estimates computed in all of those resampled datasets. To do this, we defined <code>tidy_custom.lm</code> function that will automatically bootstrap any <code>lm</code> model supplied to <code>modelsummary</code>, and replace the values in the table automatically.</p>
<p>Note that the <code>tidy_custom_lm</code> returns a data.frame with 3 columns: <code>term</code>, <code>estimate</code>, and <code>std.error</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb94"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="st"><a href="https://broom.tidymodels.org/">"broom"</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="st"><a href="https://tidyverse.tidyverse.org">"tidyverse"</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="st"><a href="https://modelr.tidyverse.org">"modelr"</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">tidy_custom.lm</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span>, <span class="va">...</span><span class="op">)</span> <span class="op">{</span></span>
<span>  <span class="co"># extract data from the model</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/model.frame.html">model.frame</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="co"># draw 500 bootstrap resamples</span></span>
<span>    <span class="fu">modelr</span><span class="fu">::</span><span class="fu"><a href="https://modelr.tidyverse.org/reference/bootstrap.html">bootstrap</a></span><span class="op">(</span>n <span class="op">=</span> <span class="fl">500</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="co"># estimate the model 500 times</span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>results <span class="op">=</span> <span class="fu"><a href="https://purrr.tidyverse.org/reference/map.html">map</a></span><span class="op">(</span><span class="va">strap</span>, <span class="op">~</span> <span class="fu"><a href="https://rdrr.io/r/stats/update.html">update</a></span><span class="op">(</span><span class="va">x</span>, data <span class="op">=</span> <span class="va">.</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="co"># extract results using `broom::tidy`</span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>results <span class="op">=</span> <span class="fu"><a href="https://purrr.tidyverse.org/reference/map.html">map</a></span><span class="op">(</span><span class="va">results</span>, <span class="va">tidy</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="co"># unnest and summarize</span></span>
<span>    <span class="fu"><a href="https://tidyr.tidyverse.org/reference/unnest.html">unnest</a></span><span class="op">(</span><span class="va">results</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">term</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html">%&gt;%</a></span></span>
<span>    <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarize</a></span><span class="op">(</span>std.error <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/sd.html">sd</a></span><span class="op">(</span><span class="va">estimate</span><span class="op">)</span>,</span>
<span>              estimate <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">estimate</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="va">mod</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">mpg</span>, <span class="va">mtcars</span><span class="op">)</span> ,</span>
<span>  <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">hp</span> <span class="op">~</span> <span class="va">mpg</span> <span class="op">+</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_r5m52sxu3xfq2f9xeogw(i, j, css_id) {
          var table = document.getElementById("tinytable_r5m52sxu3xfq2f9xeogw");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_r5m52sxu3xfq2f9xeogw(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_r5m52sxu3xfq2f9xeogw");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '14', j: 1 }, { i: '14', j: 2 },  ], css_id: 'tinytable_css_cexaxejd1n72oet4ya8c',}, 
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 },  ], css_id: 'tinytable_css_qyrm743zk2stqfkk0ac0',}, 
          { positions: [ { i: '1', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '4', j: 2 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '12', j: 2 }, { i: '2', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '8', j: 2 }, { i: '5', j: 2 }, { i: '10', j: 2 }, { i: '7', j: 2 }, { i: '9', j: 2 }, { i: '11', j: 2 }, { i: '13', j: 2 },  ], css_id: 'tinytable_css_4r21j45n2cojp7yd2vjh',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_tzqwto828kb4o89lcx0n',}, 
          { positions: [ { i: '14', j: 0 },  ], css_id: 'tinytable_css_w0fjd0stnf0sey5vkopi',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_ewz9hb3uo03f0xoinbee',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_18kcialvq6u6h5k3e7ug',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_bmdgfc9brb7ccs5iqoya',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_r5m52sxu3xfq2f9xeogw(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_cexaxejd1n72oet4ya8c, .table th.tinytable_css_cexaxejd1n72oet4ya8c { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_qyrm743zk2stqfkk0ac0, .table th.tinytable_css_qyrm743zk2stqfkk0ac0 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_4r21j45n2cojp7yd2vjh, .table th.tinytable_css_4r21j45n2cojp7yd2vjh { text-align: center; }
      .table td.tinytable_css_tzqwto828kb4o89lcx0n, .table th.tinytable_css_tzqwto828kb4o89lcx0n { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_w0fjd0stnf0sey5vkopi, .table th.tinytable_css_w0fjd0stnf0sey5vkopi { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_ewz9hb3uo03f0xoinbee, .table th.tinytable_css_ewz9hb3uo03f0xoinbee { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_18kcialvq6u6h5k3e7ug, .table th.tinytable_css_18kcialvq6u6h5k3e7ug { text-align: left; }
      .table td.tinytable_css_bmdgfc9brb7ccs5iqoya, .table th.tinytable_css_bmdgfc9brb7ccs5iqoya { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_r5m52sxu3xfq2f9xeogw" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
                <th scope="col" data-row="0" data-col="2">(2)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">326.479</td>
                  <td data-row="1" data-col="2">285.294</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(31.649)</td>
                  <td data-row="2" data-col="2">(42.226)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">mpg</td>
                  <td data-row="3" data-col="1">-9.015</td>
                  <td data-row="3" data-col="2">-10.189</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(1.468)</td>
                  <td data-row="4" data-col="2">(2.479)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1"></td>
                  <td data-row="5" data-col="2">18.062</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1"></td>
                  <td data-row="6" data-col="2">(20.802)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                  <td data-row="7" data-col="2">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.602</td>
                  <td data-row="8" data-col="2">0.614</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.589</td>
                  <td data-row="9" data-col="2">0.588</td>
                </tr>
<tr>
<td data-row="10" data-col="0">AIC</td>
                  <td data-row="10" data-col="1">336.9</td>
                  <td data-row="10" data-col="2">337.9</td>
                </tr>
<tr>
<td data-row="11" data-col="0">BIC</td>
                  <td data-row="11" data-col="1">341.3</td>
                  <td data-row="11" data-col="2">343.7</td>
                </tr>
<tr>
<td data-row="12" data-col="0">Log.Lik.</td>
                  <td data-row="12" data-col="1">-165.428</td>
                  <td data-row="12" data-col="2">-164.940</td>
                </tr>
<tr>
<td data-row="13" data-col="0">F</td>
                  <td data-row="13" data-col="1">45.460</td>
                  <td data-row="13" data-col="2">23.100</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">42.55</td>
                  <td data-row="14" data-col="2">41.91</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="fixest-fixed-effects" class="level2"><h2 class="anchored" data-anchor-id="fixest-fixed-effects">
<code>fixest</code>: Fixed effects</h2>
<section id="instrumental-variable-regression" class="level3"><h3 class="anchored" data-anchor-id="instrumental-variable-regression">Instrumental variable regression</h3>
<p>One common use-case for <code>glance_custom</code> is to include additional goodness-of-fit statistics. For example, in an instrumental variable estimation computed by the <code>fixest</code> package, we may want to include an IV-Wald statistic for the first-stage regression of each endogenous regressor:</p>
<div class="cell">
<div class="sourceCode" id="cb95"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://lrberge.github.io/fixest/">fixest</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://tidyverse.tidyverse.org">tidyverse</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># create a toy dataset</span></span>
<span><span class="va">base</span> <span class="op">&lt;-</span> <span class="va">iris</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">base</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"y"</span>, <span class="st">"x1"</span>, <span class="st">"x_endo_1"</span>, <span class="st">"x_inst_1"</span>, <span class="st">"fe"</span><span class="op">)</span></span>
<span><span class="va">base</span><span class="op">$</span><span class="va">x_inst_2</span> <span class="op">&lt;-</span> <span class="fl">0.2</span> <span class="op">*</span> <span class="va">base</span><span class="op">$</span><span class="va">y</span> <span class="op">+</span> <span class="fl">0.2</span> <span class="op">*</span> <span class="va">base</span><span class="op">$</span><span class="va">x_endo_1</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">150</span>, sd <span class="op">=</span> <span class="fl">0.5</span><span class="op">)</span></span>
<span><span class="va">base</span><span class="op">$</span><span class="va">x_endo_2</span> <span class="op">&lt;-</span> <span class="fl">0.2</span> <span class="op">*</span> <span class="va">base</span><span class="op">$</span><span class="va">y</span> <span class="op">-</span> <span class="fl">0.2</span> <span class="op">*</span> <span class="va">base</span><span class="op">$</span><span class="va">x_inst_1</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">150</span>, sd <span class="op">=</span> <span class="fl">0.5</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># estimate an instrumental variable model</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://lrberge.github.io/fixest/reference/feols.html">feols</a></span><span class="op">(</span><span class="va">y</span> <span class="op">~</span> <span class="va">x1</span> <span class="op">|</span> <span class="va">fe</span> <span class="op">|</span> <span class="va">x_endo_1</span> <span class="op">+</span> <span class="va">x_endo_2</span> <span class="op">~</span> <span class="va">x_inst_1</span> <span class="op">+</span> <span class="va">x_inst_2</span>, <span class="va">base</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># custom extractor function returns a one-row data.frame (or tibble)</span></span>
<span><span class="va">glance_custom.fixest</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="op">{</span></span>
<span>  <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span></span>
<span>    <span class="st">"Wald (x_endo_1)"</span> <span class="op">=</span> <span class="fu"><a href="https://lrberge.github.io/fixest/reference/fitstat.html">fitstat</a></span><span class="op">(</span><span class="va">x</span>, <span class="st">"ivwald"</span><span class="op">)</span><span class="op">[[</span><span class="fl">1</span><span class="op">]</span><span class="op">]</span><span class="op">$</span><span class="va">stat</span>,</span>
<span>    <span class="st">"Wald (x_endo_2)"</span> <span class="op">=</span> <span class="fu"><a href="https://lrberge.github.io/fixest/reference/fitstat.html">fitstat</a></span><span class="op">(</span><span class="va">x</span>, <span class="st">"ivwald"</span><span class="op">)</span><span class="op">[[</span><span class="fl">2</span><span class="op">]</span><span class="op">]</span><span class="op">$</span><span class="va">stat</span></span>
<span>  <span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="co"># draw table</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_6pxpvt70t1rohqucg7t8(i, j, css_id) {
          var table = document.getElementById("tinytable_6pxpvt70t1rohqucg7t8");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_6pxpvt70t1rohqucg7t8(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_6pxpvt70t1rohqucg7t8");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '18', j: 1 },  ], css_id: 'tinytable_css_wdax7fx1hlz59p825s14',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_u9pd6c5wn9l6371iosw3',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '14', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '15', j: 1 }, { i: '16', j: 1 }, { i: '17', j: 1 },  ], css_id: 'tinytable_css_e1gidvb4wsq96vh83sbt',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_4mxvbqz396baqe0qsooi',}, 
          { positions: [ { i: '18', j: 0 },  ], css_id: 'tinytable_css_oaz4b2yvfbm25a2pq2q8',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_tsc7w8l5to77jg1m2ra4',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '15', j: 0 }, { i: '16', j: 0 }, { i: '17', j: 0 },  ], css_id: 'tinytable_css_oth21skrn4k5w5a7uu3v',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_h2fxe0cglhs356clpudy',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_6pxpvt70t1rohqucg7t8(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_wdax7fx1hlz59p825s14, .table th.tinytable_css_wdax7fx1hlz59p825s14 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_u9pd6c5wn9l6371iosw3, .table th.tinytable_css_u9pd6c5wn9l6371iosw3 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_e1gidvb4wsq96vh83sbt, .table th.tinytable_css_e1gidvb4wsq96vh83sbt { text-align: center; }
      .table td.tinytable_css_4mxvbqz396baqe0qsooi, .table th.tinytable_css_4mxvbqz396baqe0qsooi { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_oaz4b2yvfbm25a2pq2q8, .table th.tinytable_css_oaz4b2yvfbm25a2pq2q8 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_tsc7w8l5to77jg1m2ra4, .table th.tinytable_css_tsc7w8l5to77jg1m2ra4 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_oth21skrn4k5w5a7uu3v, .table th.tinytable_css_oth21skrn4k5w5a7uu3v { text-align: left; }
      .table td.tinytable_css_h2fxe0cglhs356clpudy, .table th.tinytable_css_h2fxe0cglhs356clpudy { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_6pxpvt70t1rohqucg7t8" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">fit_x_endo_1</td>
                  <td data-row="1" data-col="1">1.835</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(3.822)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">fit_x_endo_2</td>
                  <td data-row="3" data-col="1">2.557</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(8.236)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">x1</td>
                  <td data-row="5" data-col="1">-0.414</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(2.699)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">150</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">-1.234</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">-1.311</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2 Within</td>
                  <td data-row="10" data-col="1">-4.858</td>
                </tr>
<tr>
<td data-row="11" data-col="0">R2 Within Adj.</td>
                  <td data-row="11" data-col="1">-4.980</td>
                </tr>
<tr>
<td data-row="12" data-col="0">AIC</td>
                  <td data-row="12" data-col="1">500.6</td>
                </tr>
<tr>
<td data-row="13" data-col="0">BIC</td>
                  <td data-row="13" data-col="1">518.7</td>
                </tr>
<tr>
<td data-row="14" data-col="0">RMSE</td>
                  <td data-row="14" data-col="1">1.23</td>
                </tr>
<tr>
<td data-row="15" data-col="0">Std.Errors</td>
                  <td data-row="15" data-col="1">by: fe</td>
                </tr>
<tr>
<td data-row="16" data-col="0">FE: fe</td>
                  <td data-row="16" data-col="1">X</td>
                </tr>
<tr>
<td data-row="17" data-col="0">Wald (x_endo_1)</td>
                  <td data-row="17" data-col="1">9.68542933525881</td>
                </tr>
<tr>
<td data-row="18" data-col="0">Wald (x_endo_2)</td>
                  <td data-row="18" data-col="1">78.2629742494862</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<div class="cell">
<div class="sourceCode" id="cb96"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/rm.html">rm</a></span><span class="op">(</span><span class="st">"glance_custom.fixest"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section><section id="customizing-fixed-effects-indicators" class="level3"><h3 class="anchored" data-anchor-id="customizing-fixed-effects-indicators">Customizing fixed effects indicators</h3>
<p>By default, fixed effects levels are indicated by a <code>X</code> mark at the bottom of the table. It is reasonably easy to customize this behavior by specifying a custom <code><a href="https://modelsummary.com/man/glance_custom.html">glance_custom()</a></code> method.</p>
<div class="cell">
<div class="sourceCode" id="cb97"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://lrberge.github.io/fixest/">fixest</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">dat</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span></span>
<span>  y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">1000</span><span class="op">)</span>,</span>
<span>  x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span><span class="op">(</span><span class="fl">1000</span><span class="op">)</span>,</span>
<span>  a <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">10</span>, <span class="fl">1000</span>, replace <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span>
<span>  b <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">10</span>, <span class="fl">1000</span>, replace <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://lrberge.github.io/fixest/reference/feols.html">feols</a></span><span class="op">(</span><span class="va">y</span> <span class="op">~</span> <span class="va">x</span> <span class="op">|</span> <span class="va">a</span> <span class="op">+</span> <span class="va">b</span>, <span class="va">dat</span><span class="op">)</span></span>
<span></span>
<span><span class="va">glance_custom.fixest</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="op">{</span></span>
<span>  <span class="va">out</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="op">)</span></span>
<span>  <span class="kw">for</span> <span class="op">(</span><span class="va">v</span> <span class="kw">in</span> <span class="va">x</span><span class="op">$</span><span class="va">fixef_vars</span><span class="op">)</span> <span class="op">{</span></span>
<span>    <span class="va">out</span><span class="op">[[</span><span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="st">"FE: "</span>, <span class="va">v</span><span class="op">)</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="st">"✓"</span></span>
<span>  <span class="op">}</span></span>
<span>  <span class="kw"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span><span class="va">out</span>, check.names <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="op">}</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/get_gof.html">get_gof</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>       aic      bic  r.squared adj.r.squared    r2.within r2.within.adjusted      rmse nobs FE: a FE: b vcov.type
1 2824.748 2922.903 0.01993342  0.0009321267 0.0007196627      -0.0003000111 0.9737852 1000     ✓     ✓     by: a</code></pre>
</div>
<div class="sourceCode" id="cb99"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_9e12468oq72e3dgwvo0c(i, j, css_id) {
          var table = document.getElementById("tinytable_9e12468oq72e3dgwvo0c");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_9e12468oq72e3dgwvo0c(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_9e12468oq72e3dgwvo0c");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '13', j: 1 },  ], css_id: 'tinytable_css_g0f78j75ttyd4dviei3k',}, 
          { positions: [ { i: '2', j: 1 },  ], css_id: 'tinytable_css_8nyz43cxlrp07gq0hiu1',}, 
          { positions: [ { i: '1', j: 1 }, { i: '6', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 },  ], css_id: 'tinytable_css_tfpzce1i1tezwfn0uidw',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_c3s62oz55xmtvcyp1x9p',}, 
          { positions: [ { i: '13', j: 0 },  ], css_id: 'tinytable_css_8uu8ti5o23vp13teyy6a',}, 
          { positions: [ { i: '2', j: 0 },  ], css_id: 'tinytable_css_qgp87tupunrl04oi2to7',}, 
          { positions: [ { i: '1', j: 0 }, { i: '6', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 },  ], css_id: 'tinytable_css_11zd3rb3q72hrrxmr9nr',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_hn8c8cbrvxc81j3cwd85',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_9e12468oq72e3dgwvo0c(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_g0f78j75ttyd4dviei3k, .table th.tinytable_css_g0f78j75ttyd4dviei3k { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_8nyz43cxlrp07gq0hiu1, .table th.tinytable_css_8nyz43cxlrp07gq0hiu1 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_tfpzce1i1tezwfn0uidw, .table th.tinytable_css_tfpzce1i1tezwfn0uidw { text-align: center; }
      .table td.tinytable_css_c3s62oz55xmtvcyp1x9p, .table th.tinytable_css_c3s62oz55xmtvcyp1x9p { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_8uu8ti5o23vp13teyy6a, .table th.tinytable_css_8uu8ti5o23vp13teyy6a { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_qgp87tupunrl04oi2to7, .table th.tinytable_css_qgp87tupunrl04oi2to7 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_11zd3rb3q72hrrxmr9nr, .table th.tinytable_css_11zd3rb3q72hrrxmr9nr { text-align: left; }
      .table td.tinytable_css_hn8c8cbrvxc81j3cwd85, .table th.tinytable_css_hn8c8cbrvxc81j3cwd85 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_9e12468oq72e3dgwvo0c" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">x</td>
                  <td data-row="1" data-col="1">-0.027</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.034)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Num.Obs.</td>
                  <td data-row="3" data-col="1">1000</td>
                </tr>
<tr>
<td data-row="4" data-col="0">R2</td>
                  <td data-row="4" data-col="1">0.020</td>
                </tr>
<tr>
<td data-row="5" data-col="0">R2 Adj.</td>
                  <td data-row="5" data-col="1">0.001</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2 Within</td>
                  <td data-row="6" data-col="1">0.001</td>
                </tr>
<tr>
<td data-row="7" data-col="0">R2 Within Adj.</td>
                  <td data-row="7" data-col="1">-0.000</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">2824.7</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">2922.9</td>
                </tr>
<tr>
<td data-row="10" data-col="0">RMSE</td>
                  <td data-row="10" data-col="1">0.97</td>
                </tr>
<tr>
<td data-row="11" data-col="0">Std.Errors</td>
                  <td data-row="11" data-col="1">by: a</td>
                </tr>
<tr>
<td data-row="12" data-col="0">FE: a</td>
                  <td data-row="12" data-col="1">✓</td>
                </tr>
<tr>
<td data-row="13" data-col="0">FE: b</td>
                  <td data-row="13" data-col="1">✓</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section></section><section id="multiple-imputation" class="level2"><h2 class="anchored" data-anchor-id="multiple-imputation">Multiple imputation</h2>
<p><code>modelsummary</code> can pool and display analyses on several datasets imputed using the <code>mice</code> or <code>Amelia</code> packages. This code illustrates how:</p>
<div class="cell">
<div class="sourceCode" id="cb100"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/amices/mice">mice</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://gking.harvard.edu/amelia">Amelia</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Download data from `Rdatasets`</span></span>
<span><span class="va">url</span> <span class="op">&lt;-</span> <span class="st">'https://vincentarelbundock.github.io/Rdatasets/csv/HistData/Guerry.csv'</span></span>
<span><span class="va">dat</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/utils/read.table.html">read.csv</a></span><span class="op">(</span><span class="va">url</span><span class="op">)</span><span class="op">[</span>, <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">'Clergy'</span>, <span class="st">'Commerce'</span>, <span class="st">'Literacy'</span><span class="op">)</span><span class="op">]</span></span>
<span></span>
<span><span class="co"># Insert missing values</span></span>
<span><span class="va">dat</span><span class="op">$</span><span class="va">Clergy</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fu"><a href="https://rdrr.io/r/base/nrow.html">nrow</a></span><span class="op">(</span><span class="va">dat</span><span class="op">)</span>, <span class="fl">10</span><span class="op">)</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="cn">NA</span></span>
<span><span class="va">dat</span><span class="op">$</span><span class="va">Commerce</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fu"><a href="https://rdrr.io/r/base/nrow.html">nrow</a></span><span class="op">(</span><span class="va">dat</span><span class="op">)</span>, <span class="fl">10</span><span class="op">)</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="cn">NA</span></span>
<span><span class="va">dat</span><span class="op">$</span><span class="va">Literacy</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fu"><a href="https://rdrr.io/r/base/nrow.html">nrow</a></span><span class="op">(</span><span class="va">dat</span><span class="op">)</span>, <span class="fl">10</span><span class="op">)</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="cn">NA</span></span>
<span></span>
<span><span class="co"># Impute with `mice` and `Amelia`</span></span>
<span><span class="va">dat_mice</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://amices.org/mice/reference/mice.html">mice</a></span><span class="op">(</span><span class="va">dat</span>, m <span class="op">=</span> <span class="fl">5</span>, printFlag <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span><span class="va">dat_amelia</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/Amelia/man/amelia.html">amelia</a></span><span class="op">(</span><span class="va">dat</span>, m <span class="op">=</span> <span class="fl">5</span>, p2s <span class="op">=</span> <span class="fl">0</span><span class="op">)</span><span class="op">$</span><span class="va">imputations</span></span>
<span></span>
<span><span class="co"># Estimate models</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="va">mod</span><span class="op">[[</span><span class="st">'Listwise deletion'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">Clergy</span> <span class="op">~</span> <span class="va">Literacy</span> <span class="op">+</span> <span class="va">Commerce</span>, <span class="va">dat</span><span class="op">)</span></span>
<span><span class="va">mod</span><span class="op">[[</span><span class="st">'Mice'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html">with</a></span><span class="op">(</span><span class="va">dat_mice</span>, <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">Clergy</span> <span class="op">~</span> <span class="va">Literacy</span> <span class="op">+</span> <span class="va">Commerce</span><span class="op">)</span><span class="op">)</span> </span>
<span><span class="va">mod</span><span class="op">[[</span><span class="st">'Amelia'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="va">dat_amelia</span>, <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">Clergy</span> <span class="op">~</span> <span class="va">Literacy</span> <span class="op">+</span> <span class="va">Commerce</span>, <span class="va">x</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Pool results</span></span>
<span><span class="va">mod</span><span class="op">[[</span><span class="st">'Mice'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu">mice</span><span class="fu">::</span><span class="fu"><a href="https://amices.org/mice/reference/pool.html">pool</a></span><span class="op">(</span><span class="va">mod</span><span class="op">[[</span><span class="st">'Mice'</span><span class="op">]</span><span class="op">]</span><span class="op">)</span></span>
<span><span class="va">mod</span><span class="op">[[</span><span class="st">'Amelia'</span><span class="op">]</span><span class="op">]</span> <span class="op">&lt;-</span> <span class="fu">mice</span><span class="fu">::</span><span class="fu"><a href="https://amices.org/mice/reference/pool.html">pool</a></span><span class="op">(</span><span class="va">mod</span><span class="op">[[</span><span class="st">'Amelia'</span><span class="op">]</span><span class="op">]</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Summarize</span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_y3s13mh4xf8fzv695l8r(i, j, css_id) {
          var table = document.getElementById("tinytable_y3s13mh4xf8fzv695l8r");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_y3s13mh4xf8fzv695l8r(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_y3s13mh4xf8fzv695l8r");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '15', j: 2 }, { i: '15', j: 1 }, { i: '15', j: 3 },  ], css_id: 'tinytable_css_hfxemufogf1mmu0486x8',}, 
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 }, { i: '6', j: 3 },  ], css_id: 'tinytable_css_uksebycg9nl9092si960',}, 
          { positions: [ { i: '1', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '2', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '14', j: 1 }, { i: '12', j: 2 }, { i: '3', j: 1 }, { i: '1', j: 2 }, { i: '2', j: 2 }, { i: '3', j: 2 }, { i: '4', j: 2 }, { i: '5', j: 2 }, { i: '3', j: 3 }, { i: '7', j: 2 }, { i: '8', j: 2 }, { i: '9', j: 2 }, { i: '10', j: 2 }, { i: '11', j: 2 }, { i: '9', j: 3 }, { i: '13', j: 2 }, { i: '14', j: 2 }, { i: '12', j: 3 }, { i: '13', j: 3 }, { i: '1', j: 3 }, { i: '2', j: 3 }, { i: '7', j: 3 }, { i: '4', j: 3 }, { i: '5', j: 3 }, { i: '10', j: 3 }, { i: '11', j: 3 }, { i: '8', j: 3 }, { i: '14', j: 3 },  ], css_id: 'tinytable_css_9nvfy646ih0fzxf7k9z5',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 3 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_b7bs1xw8ak07woaplmtv',}, 
          { positions: [ { i: '15', j: 0 },  ], css_id: 'tinytable_css_p9chmwemvk5g7ml4n3v6',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_pp573355k5c9lsrchjj4',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 },  ], css_id: 'tinytable_css_1tylogv9unl3q7yvhfkl',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_w6vonwl1wofqlbbsy9fx',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_y3s13mh4xf8fzv695l8r(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_hfxemufogf1mmu0486x8, .table th.tinytable_css_hfxemufogf1mmu0486x8 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_uksebycg9nl9092si960, .table th.tinytable_css_uksebycg9nl9092si960 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_9nvfy646ih0fzxf7k9z5, .table th.tinytable_css_9nvfy646ih0fzxf7k9z5 { text-align: center; }
      .table td.tinytable_css_b7bs1xw8ak07woaplmtv, .table th.tinytable_css_b7bs1xw8ak07woaplmtv { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_p9chmwemvk5g7ml4n3v6, .table th.tinytable_css_p9chmwemvk5g7ml4n3v6 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_pp573355k5c9lsrchjj4, .table th.tinytable_css_pp573355k5c9lsrchjj4 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_1tylogv9unl3q7yvhfkl, .table th.tinytable_css_1tylogv9unl3q7yvhfkl { text-align: left; }
      .table td.tinytable_css_w6vonwl1wofqlbbsy9fx, .table th.tinytable_css_w6vonwl1wofqlbbsy9fx { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_y3s13mh4xf8fzv695l8r" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">Listwise deletion</th>
                <th scope="col" data-row="0" data-col="2">Mice</th>
                <th scope="col" data-row="0" data-col="3">Amelia</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">71.433</td>
                  <td data-row="1" data-col="2">77.026</td>
                  <td data-row="1" data-col="3">74.936</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(12.814)</td>
                  <td data-row="2" data-col="2">(11.364)</td>
                  <td data-row="2" data-col="3">(11.348)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Literacy</td>
                  <td data-row="3" data-col="1">-0.402</td>
                  <td data-row="3" data-col="2">-0.583</td>
                  <td data-row="3" data-col="3">-0.501</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.214)</td>
                  <td data-row="4" data-col="2">(0.194)</td>
                  <td data-row="4" data-col="3">(0.175)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Commerce</td>
                  <td data-row="5" data-col="1">-0.356</td>
                  <td data-row="5" data-col="2">-0.262</td>
                  <td data-row="5" data-col="3">-0.292</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.142)</td>
                  <td data-row="6" data-col="2">(0.122)</td>
                  <td data-row="6" data-col="3">(0.134)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">60</td>
                  <td data-row="7" data-col="2">86</td>
                  <td data-row="7" data-col="3">85</td>
                </tr>
<tr>
<td data-row="8" data-col="0">Num.Imp.</td>
                  <td data-row="8" data-col="1"></td>
                  <td data-row="8" data-col="2">5</td>
                  <td data-row="8" data-col="3">5</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2</td>
                  <td data-row="9" data-col="1">0.110</td>
                  <td data-row="9" data-col="2">0.125</td>
                  <td data-row="9" data-col="3">0.105</td>
                </tr>
<tr>
<td data-row="10" data-col="0">R2 Adj.</td>
                  <td data-row="10" data-col="1">0.079</td>
                  <td data-row="10" data-col="2">0.103</td>
                  <td data-row="10" data-col="3">0.083</td>
                </tr>
<tr>
<td data-row="11" data-col="0">AIC</td>
                  <td data-row="11" data-col="1">555.4</td>
                  <td data-row="11" data-col="2"></td>
                  <td data-row="11" data-col="3"></td>
                </tr>
<tr>
<td data-row="12" data-col="0">BIC</td>
                  <td data-row="12" data-col="1">563.8</td>
                  <td data-row="12" data-col="2"></td>
                  <td data-row="12" data-col="3"></td>
                </tr>
<tr>
<td data-row="13" data-col="0">Log.Lik.</td>
                  <td data-row="13" data-col="1">-273.703</td>
                  <td data-row="13" data-col="2"></td>
                  <td data-row="13" data-col="3"></td>
                </tr>
<tr>
<td data-row="14" data-col="0">F</td>
                  <td data-row="14" data-col="1">3.515</td>
                  <td data-row="14" data-col="2"></td>
                  <td data-row="14" data-col="3"></td>
                </tr>
<tr>
<td data-row="15" data-col="0">RMSE</td>
                  <td data-row="15" data-col="1">23.17</td>
                  <td data-row="15" data-col="2"></td>
                  <td data-row="15" data-col="3"></td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section></section><section id="faq" class="level1"><h1>FAQ</h1>
<section id="stack-overflow-is-useful" class="level2"><h2 class="anchored" data-anchor-id="stack-overflow-is-useful">Stack Overflow is useful</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/72266343/how-do-i-get-standardized-beta-coefficients-using-modelsummary-in-r-and-how-to/72267006#72267006">Standardized coefficients</a></li>
<li><a href="https://stackoverflow.com/questions/72729369/adding-coefficient-group-titles-to-modelsummary-output/72736415#72736415">Row group labels</a></li>
<li><a href="https://stackoverflow.com/questions/73120996/how-to-export-kableextra-output-in-r-to-word/73123552#73123552">Customizing Word tables</a></li>
<li><a href="https://stackoverflow.com/questions/75991478/how-to-add-a-p-value-to-a-correlation-table-while-using-model-summary-package-in/75997827#75997827">How to add p values to <code>datasummary_correlation</code></a></li>
<li><a href="https://stackoverflow.com/questions/78568013/how-to-report-an-object-of-class-htest-using-modelsummary-in-r"><code>htest</code> objects.</a></li>
</ul></section><section id="where-can-i-get-help" class="level2"><h2 class="anchored" data-anchor-id="where-can-i-get-help">Where can I get help?</h2>
<p>First, please read the documentation in <code><a href="https://modelsummary.com/man/modelsummary.html">?modelsummary</a></code> and on <a href="https://modelsummary.com/">the <code>modelsummary</code> website.</a> The website includes dozens of worked examples and a lot of detailed explanation.</p>
<p>Second, try to <a href="https://stackoverflow.com/search?tab=newest&amp;q=%5br%5d%20modelsummary">use the <code>[modelsummary]</code> tag on StackOverflow.</a></p>
<p>Third, if you think you found a bug or have a feature request, please file it on the Github issue tracker:</p>
</section><section id="how-can-i-add-or-modify-statistics-in-a-table" class="level2"><h2 class="anchored" data-anchor-id="how-can-i-add-or-modify-statistics-in-a-table">How can I add or modify statistics in a table?</h2>
<p>See the detailed documentation in the <a href="https://modelsummary.com/vignettes/modelsummary.html">“Adding and Customizing Models” section of the <code>modelsummary</code> website.</a></p>
</section><section id="how-does-modelsummary-extract-estimates-and-goodness-of-fit-statistics" class="level2"><h2 class="anchored" data-anchor-id="how-does-modelsummary-extract-estimates-and-goodness-of-fit-statistics">How does <code>modelsummary</code> extract estimates and goodness-of-fit statistics?</h2>
<p>A <code>modelsummary</code> table is divided in two parts: “Estimates” (top of the table) and “Goodness-of-fit” (bottom of the table). To populate those two parts, <code>modelsummary</code> tries using the <code>broom</code>, <code>parameters</code> and <code>performance</code> packages in sequence.</p>
<p>Estimates:</p>
<ol type="1">
<li>Try the <code><a href="https://generics.r-lib.org/reference/tidy.html">broom::tidy</a></code> function to see if that package supports this model type, or if the user defined a custom <code>tidy</code> function in their global environment. If this fails…</li>
<li>Try the <code><a href="https://easystats.github.io/parameters/reference/model_parameters.html">parameters::model_parameters</a></code> function to see if the <code>parameters</code> package supports this model type.</li>
</ol>
<p>Goodness-of-fit:</p>
<ol type="1">
<li>Try the <code><a href="https://easystats.github.io/performance/reference/model_performance.html">performance::model_performance</a></code> function to see if the <code>performance</code> package supports this model type.</li>
<li>Try the <code><a href="https://generics.r-lib.org/reference/glance.html">broom::glance</a></code> function to see if that package supports this model type, or if the user defined a custom <code>glance</code> function in their global environment. If this fails…</li>
</ol>
<p>You can change the order in which those steps are executed by setting a global option:</p>
<div class="cell">
<div class="sourceCode" id="cb101"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># tidymodels: broom </span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_get <span class="op">=</span> <span class="st">"broom"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># easystats: performance + parameters</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html">options</a></span><span class="op">(</span>modelsummary_get <span class="op">=</span> <span class="st">"easystats"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>If all of this fails, <code>modelsummary</code> will return an error message.</p>
<p>If you have problems with a model object, you can often diagnose the problem by running the following commands from a <em>clean</em> R session:</p>
<div class="sourceCode" id="cb102"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="co"># see if parameters and performance support your model type</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://easystats.github.io/parameters/">parameters</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://easystats.github.io/performance/">performance</a></span><span class="op">)</span></span>
<span><span class="fu"><a href="https://easystats.github.io/parameters/reference/model_parameters.html">model_parameters</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://easystats.github.io/performance/reference/model_performance.html">model_performance</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># see if broom supports your model type</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://broom.tidymodels.org/">broom</a></span><span class="op">)</span></span>
<span><span class="fu"><a href="https://generics.r-lib.org/reference/tidy.html">tidy</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://generics.r-lib.org/reference/glance.html">glance</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># see if broom.mixed supports your model type</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/bbolker/broom.mixed">broom.mixed</a></span><span class="op">)</span></span>
<span><span class="fu"><a href="https://generics.r-lib.org/reference/tidy.html">tidy</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://generics.r-lib.org/reference/glance.html">glance</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>If none of these options work, you can create your own <code>tidy</code> and <code>glance</code> methods, as described in the <a href="https://modelsummary.com/vignettes/modelsummary.html#adding-new-models-1">Adding new models section.</a></p>
<p>If one of the extractor functions does not work well or takes too long to process, you can define a new “custom” model class and choose your own extractors, as described in the <a href="https://modelsummary.com/vignettes/modelsummary.html#adding-new-models-1">Adding new models section.</a></p>
</section><section id="how-can-i-speed-up-modelsummary" class="level2"><h2 class="anchored" data-anchor-id="how-can-i-speed-up-modelsummary">How can I speed up <code>modelsummary</code>?</h2>
<p>The <code>modelsummary</code> function, by itself, is <em>not</em> slow: it should only take a couple seconds to produce a table in any output format. However, sometimes it can be computationally expensive (and long) to extract estimates and to compute goodness-of-fit statistics for your model.</p>
<p>The main options to speed up <code>modelsummary</code> are:</p>
<ol type="1">
<li>Set <code>gof_map=NA</code> to avoid computing expensive goodness-of-fit statistics.</li>
<li>Use the <code>easystats</code> extractor functions and the <code>metrics</code> argument to avoid computing expensive statistics (see below for an example).</li>
<li>Use parallel computation if you are summarizing multiple models. See the “Parallel computation” section in the <code><a href="https://modelsummary.com/man/modelsummary.html">?modelsummary</a></code> documentation.</li>
</ol>
<p>To diagnose the slowdown and find the bottleneck, you can try to benchmark the various extractor functions:</p>
<div class="cell">
<div class="sourceCode" id="cb103"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/jabiru/tictoc">tictoc</a></span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/utils/data.html">data</a></span><span class="op">(</span><span class="va">trade</span><span class="op">)</span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">drat</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">tic</a></span><span class="op">(</span><span class="st">"tidy"</span><span class="op">)</span></span>
<span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu">broom</span><span class="fu">::</span><span class="fu"><a href="https://generics.r-lib.org/reference/tidy.html">tidy</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">toc</a></span><span class="op">(</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>tidy: 0.001 sec elapsed</code></pre>
</div>
<div class="sourceCode" id="cb105"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">tic</a></span><span class="op">(</span><span class="st">"glance"</span><span class="op">)</span></span>
<span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu">broom</span><span class="fu">::</span><span class="fu"><a href="https://generics.r-lib.org/reference/glance.html">glance</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">toc</a></span><span class="op">(</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>glance: 0.001 sec elapsed</code></pre>
</div>
<div class="sourceCode" id="cb107"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">tic</a></span><span class="op">(</span><span class="st">"parameters"</span><span class="op">)</span></span>
<span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu">parameters</span><span class="fu">::</span><span class="fu"><a href="https://easystats.github.io/parameters/reference/model_parameters.html">parameters</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">toc</a></span><span class="op">(</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>parameters: 0.013 sec elapsed</code></pre>
</div>
<div class="sourceCode" id="cb109"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">tic</a></span><span class="op">(</span><span class="st">"performance"</span><span class="op">)</span></span>
<span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu">performance</span><span class="fu">::</span><span class="fu"><a href="https://easystats.github.io/performance/reference/model_performance.html">performance</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/pkg/tictoc/man/tic.html">toc</a></span><span class="op">(</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>performance: 0.013 sec elapsed</code></pre>
</div>
</div>
<p>In my experience, the main bottleneck tends to be computing goodness-of-fit statistics. The <code>performance</code> extractor allows users to specify a <code>metrics</code> argument to select a subset of GOF to include. Using this can speedup things considerably.</p>
<p>We call <code>modelsummary</code> with the <code>metrics</code> argument:</p>
<div class="cell">
<div class="sourceCode" id="cb111"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, metrics <span class="op">=</span> <span class="st">"rmse"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_aa6255c6ub80nfmyugqf(i, j, css_id) {
          var table = document.getElementById("tinytable_aa6255c6ub80nfmyugqf");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_aa6255c6ub80nfmyugqf(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_aa6255c6ub80nfmyugqf");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '13', j: 1 },  ], css_id: 'tinytable_css_x3l3tvl6r1o71f089p2g',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_77456nq3iqw0kmqk3m03',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 },  ], css_id: 'tinytable_css_gf5vr6pqf12yy56fb7ci',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_itkr841fspoqwwhgoe02',}, 
          { positions: [ { i: '13', j: 0 },  ], css_id: 'tinytable_css_jtmqco4a23lfyj8urx9r',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_gggrqlvbdv64lrmczylw',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 },  ], css_id: 'tinytable_css_l19r6s7u3ffasq6mib6a',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_xd3x71yd6y5hrakqbhz4',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_aa6255c6ub80nfmyugqf(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_x3l3tvl6r1o71f089p2g, .table th.tinytable_css_x3l3tvl6r1o71f089p2g { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_77456nq3iqw0kmqk3m03, .table th.tinytable_css_77456nq3iqw0kmqk3m03 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_gf5vr6pqf12yy56fb7ci, .table th.tinytable_css_gf5vr6pqf12yy56fb7ci { text-align: center; }
      .table td.tinytable_css_itkr841fspoqwwhgoe02, .table th.tinytable_css_itkr841fspoqwwhgoe02 { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_jtmqco4a23lfyj8urx9r, .table th.tinytable_css_jtmqco4a23lfyj8urx9r { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_gggrqlvbdv64lrmczylw, .table th.tinytable_css_gggrqlvbdv64lrmczylw { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_l19r6s7u3ffasq6mib6a, .table th.tinytable_css_l19r6s7u3ffasq6mib6a { text-align: left; }
      .table td.tinytable_css_xd3x71yd6y5hrakqbhz4, .table th.tinytable_css_xd3x71yd6y5hrakqbhz4 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_aa6255c6ub80nfmyugqf" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">10.790</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(5.078)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">-0.052</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.009)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1">4.698</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(1.192)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.741</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.723</td>
                </tr>
<tr>
<td data-row="10" data-col="0">AIC</td>
                  <td data-row="10" data-col="1">169.5</td>
                </tr>
<tr>
<td data-row="11" data-col="0">BIC</td>
                  <td data-row="11" data-col="1">175.4</td>
                </tr>
<tr>
<td data-row="12" data-col="0">Log.Lik.</td>
                  <td data-row="12" data-col="1">-80.752</td>
                </tr>
<tr>
<td data-row="13" data-col="0">F</td>
                  <td data-row="13" data-col="1">41.522</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="escaped-latex-characters" class="level2"><h2 class="anchored" data-anchor-id="escaped-latex-characters">Escaped LaTeX characters</h2>
<p>Sometimes, users want to include raw LaTeX commands in their tables, such as coefficient names including math mode: <code>Apple $\times$ Orange</code>. The result of these attempts is often a weird string such as: <code>\$\textbackslash{}times\$</code> instead of proper LaTeX-rendered characters.</p>
<p>The source of the problem is that <code>kableExtra</code>, default table-making package in <code>modelsummary</code>, automatically escapes weird characters to make sure that your tables compile properly in LaTeX. To avoid this, we need to pass the <code>escape=FALSE</code> to <code>modelsummary</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb112"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, escape <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section><section id="bayesian-models" class="level2"><h2 class="anchored" data-anchor-id="bayesian-models">Bayesian models</h2>
<p>Many bayesian models are supported out-of-the-box, including those produced by the <code>rstanarm</code> and <code>brms</code> packages. The statistics available for bayesian models are slightly different than those available for most frequentist models. Users can call <code>get_estimates</code> to see what is available:</p>
<div class="cell">
<div class="sourceCode" id="cb113"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://mc-stan.org/rstanarm/">rstanarm</a></span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>This is rstanarm version 2.32.1</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>- See https://mc-stan.org/rstanarm/articles/priors for changes to default priors!</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>- Default priors may change, so it's safest to specify priors, even if equivalent to the defaults.</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>- For execution on a local, multicore CPU with excess RAM we recommend calling</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>  options(mc.cores = parallel::detectCores())</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>
Attaching package: 'rstanarm'</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following object is masked from 'package:fixest':

    se</code></pre>
</div>
<div class="sourceCode" id="cb121"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://mc-stan.org/rstanarm/reference/stan_glm.html">stan_glm</a></span><span class="op">(</span><span class="va">am</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="va">drat</span>, data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<div class="sourceCode" id="cb122"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/get_estimates.html">get_estimates</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>         term      estimate         mad conf.level     conf.low   conf.high prior.distribution prior.location prior.scale group std.error statistic p.value
1 (Intercept) -2.2348638873 0.594269709       0.95 -3.411608206 -1.02916476             normal        0.40625  1.24747729              NA        NA      NA
2          hp  0.0007070286 0.001081193       0.95 -0.001454397  0.00281591             normal        0.00000  0.01819465              NA        NA      NA
3        drat  0.7064079877 0.136994251       0.95  0.430521588  0.97808006             normal        0.00000  2.33313429              NA        NA      NA</code></pre>
</div>
</div>
<p>This shows that there is no <code>std.error</code> column, but that there is a <code>mad</code> statistic (mean absolute deviation). So we can do:</p>
<div class="cell">
<div class="sourceCode" id="cb124"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, statistic <span class="op">=</span> <span class="st">"mad"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>Warning: 
`modelsummary` uses the `performance` package to extract goodness-of-fit
statistics from models of this class. You can specify the statistics you wish
to compute by supplying a `metrics` argument to `modelsummary`, which will then
push it forward to `performance`. Acceptable values are: "all", "common",
"none", or a character vector of metrics names. For example: `modelsummary(mod,
metrics = c("RMSE", "R2")` Note that some metrics are computationally
expensive. See `?performance::performance` for details.
 This warning appears once per session.</code></pre>
</div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_3fec5q5xktwe5fue5p9c(i, j, css_id) {
          var table = document.getElementById("tinytable_3fec5q5xktwe5fue5p9c");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_3fec5q5xktwe5fue5p9c(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_3fec5q5xktwe5fue5p9c");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 },  ], css_id: 'tinytable_css_uqhcwjai07h9cg1dax4v',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_7i5zrmthwiz191fjj1aq',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '14', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '15', j: 1 },  ], css_id: 'tinytable_css_9spw1fl3x7torwxjz6l3',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_knamgm64w3jt57oalg7y',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_o68i1z2uzgv3dzkkxp8r',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_vts60ihfb8gh4zkbxjs4',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_lhcnl6lcog6053yvo6td',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_67om3054fts0kh0w06gs',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_3fec5q5xktwe5fue5p9c(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_uqhcwjai07h9cg1dax4v, .table th.tinytable_css_uqhcwjai07h9cg1dax4v { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_7i5zrmthwiz191fjj1aq, .table th.tinytable_css_7i5zrmthwiz191fjj1aq { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_9spw1fl3x7torwxjz6l3, .table th.tinytable_css_9spw1fl3x7torwxjz6l3 { text-align: center; }
      .table td.tinytable_css_knamgm64w3jt57oalg7y, .table th.tinytable_css_knamgm64w3jt57oalg7y { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_o68i1z2uzgv3dzkkxp8r, .table th.tinytable_css_o68i1z2uzgv3dzkkxp8r { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_vts60ihfb8gh4zkbxjs4, .table th.tinytable_css_vts60ihfb8gh4zkbxjs4 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_lhcnl6lcog6053yvo6td, .table th.tinytable_css_lhcnl6lcog6053yvo6td { text-align: left; }
      .table td.tinytable_css_67om3054fts0kh0w06gs, .table th.tinytable_css_67om3054fts0kh0w06gs { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_3fec5q5xktwe5fue5p9c" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">-2.235</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.594)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">0.001</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.001)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1">0.706</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.137)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.502</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.434</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-12.043</td>
                </tr>
<tr>
<td data-row="11" data-col="0">ELPD</td>
                  <td data-row="11" data-col="1">-15.0</td>
                </tr>
<tr>
<td data-row="12" data-col="0">ELPD s.e.</td>
                  <td data-row="12" data-col="1">3.1</td>
                </tr>
<tr>
<td data-row="13" data-col="0">LOOIC</td>
                  <td data-row="13" data-col="1">30.1</td>
                </tr>
<tr>
<td data-row="14" data-col="0">LOOIC s.e.</td>
                  <td data-row="14" data-col="1">6.2</td>
                </tr>
<tr>
<td data-row="15" data-col="0">WAIC</td>
                  <td data-row="15" data-col="1">29.9</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">0.34</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>As noted in <a href="https://modelsummary.com/reference/modelsummary.html">the <code>modelsummary()</code> documentation</a>, model results are extracted using the <code>parameters</code> package. Users can pass additional arguments to <code><a href="https://modelsummary.com/man/modelsummary.html">modelsummary()</a></code>, which will then push forward those arguments to the <code><a href="https://easystats.github.io/parameters/reference/model_parameters.html">parameters::parameters</a></code> function to change the results. For example, <a href="https://easystats.github.io/parameters/reference/model_parameters.html">the <code>parameters</code> documentation</a> for bayesian models shows that there is a <code>centrality</code> argument, which allows users to report the mean and standard deviation of the posterior distribution, instead of the median and MAD:</p>
<div class="cell">
<div class="sourceCode" id="cb126"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/get_estimates.html">get_estimates</a></span><span class="op">(</span><span class="va">mod</span>, centrality <span class="op">=</span> <span class="st">"mean"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>         term      estimate     std.dev conf.level     conf.low   conf.high prior.distribution prior.location prior.scale group std.error statistic p.value
1 (Intercept) -2.2236789904 0.615407681       0.95 -3.411608206 -1.02916476             normal        0.40625  1.24747729              NA        NA      NA
2          hp  0.0006952076 0.001097592       0.95 -0.001454397  0.00281591             normal        0.00000  0.01819465              NA        NA      NA
3        drat  0.7032522160 0.142433580       0.95  0.430521588  0.97808006             normal        0.00000  2.33313429              NA        NA      NA</code></pre>
</div>
<div class="sourceCode" id="cb128"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>, statistic <span class="op">=</span> <span class="st">"std.dev"</span>, centrality <span class="op">=</span> <span class="st">"mean"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_t2ddadbwua0awzargo38(i, j, css_id) {
          var table = document.getElementById("tinytable_t2ddadbwua0awzargo38");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_t2ddadbwua0awzargo38(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_t2ddadbwua0awzargo38");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '16', j: 1 },  ], css_id: 'tinytable_css_sqgo59t0aryl1zuw75kj',}, 
          { positions: [ { i: '6', j: 1 },  ], css_id: 'tinytable_css_muqwwi2ghptsv72686yc',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '10', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 }, { i: '14', j: 1 }, { i: '11', j: 1 }, { i: '12', j: 1 }, { i: '13', j: 1 }, { i: '15', j: 1 },  ], css_id: 'tinytable_css_9bi9g0tp4oznf19w74pb',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_zpinpwccrj8n3q9132lb',}, 
          { positions: [ { i: '16', j: 0 },  ], css_id: 'tinytable_css_9kmhaeh7a9v8cntiphg3',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_3393cz7daashd6l6v539',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '10', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 }, { i: '14', j: 0 }, { i: '11', j: 0 }, { i: '12', j: 0 }, { i: '13', j: 0 }, { i: '15', j: 0 },  ], css_id: 'tinytable_css_6ybw516mbnc9y8diewgt',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_zlsac56wrojgjdct3buf',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_t2ddadbwua0awzargo38(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_sqgo59t0aryl1zuw75kj, .table th.tinytable_css_sqgo59t0aryl1zuw75kj { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_muqwwi2ghptsv72686yc, .table th.tinytable_css_muqwwi2ghptsv72686yc { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_9bi9g0tp4oznf19w74pb, .table th.tinytable_css_9bi9g0tp4oznf19w74pb { text-align: center; }
      .table td.tinytable_css_zpinpwccrj8n3q9132lb, .table th.tinytable_css_zpinpwccrj8n3q9132lb { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_9kmhaeh7a9v8cntiphg3, .table th.tinytable_css_9kmhaeh7a9v8cntiphg3 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_3393cz7daashd6l6v539, .table th.tinytable_css_3393cz7daashd6l6v539 { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_6ybw516mbnc9y8diewgt, .table th.tinytable_css_6ybw516mbnc9y8diewgt { text-align: left; }
      .table td.tinytable_css_zlsac56wrojgjdct3buf, .table th.tinytable_css_zlsac56wrojgjdct3buf { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_t2ddadbwua0awzargo38" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">-2.224</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(0.615)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">hp</td>
                  <td data-row="3" data-col="1">0.001</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.001)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">drat</td>
                  <td data-row="5" data-col="1">0.703</td>
                </tr>
<tr>
<td data-row="6" data-col="0"></td>
                  <td data-row="6" data-col="1">(0.142)</td>
                </tr>
<tr>
<td data-row="7" data-col="0">Num.Obs.</td>
                  <td data-row="7" data-col="1">32</td>
                </tr>
<tr>
<td data-row="8" data-col="0">R2</td>
                  <td data-row="8" data-col="1">0.502</td>
                </tr>
<tr>
<td data-row="9" data-col="0">R2 Adj.</td>
                  <td data-row="9" data-col="1">0.434</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-12.043</td>
                </tr>
<tr>
<td data-row="11" data-col="0">ELPD</td>
                  <td data-row="11" data-col="1">-15.0</td>
                </tr>
<tr>
<td data-row="12" data-col="0">ELPD s.e.</td>
                  <td data-row="12" data-col="1">3.1</td>
                </tr>
<tr>
<td data-row="13" data-col="0">LOOIC</td>
                  <td data-row="13" data-col="1">30.1</td>
                </tr>
<tr>
<td data-row="14" data-col="0">LOOIC s.e.</td>
                  <td data-row="14" data-col="1">6.2</td>
                </tr>
<tr>
<td data-row="15" data-col="0">WAIC</td>
                  <td data-row="15" data-col="1">29.9</td>
                </tr>
<tr>
<td data-row="16" data-col="0">RMSE</td>
                  <td data-row="16" data-col="1">0.34</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>We can also get additional test statistics using the <code>test</code> argument:</p>
<div class="cell">
<div class="sourceCode" id="cb129"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/get_estimates.html">get_estimates</a></span><span class="op">(</span><span class="va">mod</span>, test <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"pd"</span>, <span class="st">"rope"</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>         term      estimate         mad conf.level     conf.low   conf.high      pd rope.percentage prior.distribution prior.location prior.scale group std.error statistic p.value
1 (Intercept) -2.2348638873 0.594269709       0.95 -3.411608206 -1.02916476 0.99925               0             normal        0.40625  1.24747729              NA        NA      NA
2          hp  0.0007070286 0.001081193       0.95 -0.001454397  0.00281591 0.74000               1             normal        0.00000  0.01819465              NA        NA      NA
3        drat  0.7064079877 0.136994251       0.95  0.430521588  0.97808006 1.00000               0             normal        0.00000  2.33313429              NA        NA      NA</code></pre>
</div>
</div>
</section><section id="factor-labels" class="level2"><h2 class="anchored" data-anchor-id="factor-labels">Factor labels</h2>
<p>Often, it is useful to include the reference level of a factor variable with an emtpy line. We can do so easily by passing the <code>include_reference</code> argument to <code><a href="https://modelsummary.com/man/modelsummary.html">modelsummary()</a></code>. This argument will be pushed froward to the <code><a href="https://easystats.github.io/parameters/reference/model_parameters.html">parameters::model_parameters()</a></code> function which is used to extract coefficients from model objects.</p>
<p>In this example, we also use the <code><a href="https://vincentarelbundock.github.io/tinytable/man/group_tt.html">group_tt()</a></code> function from <code>tinytable</code> to add a group label identifying the factor variable:</p>
<div class="cell">
<div class="sourceCode" id="cb131"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://vincentarelbundock.github.io/tinytable/">tinytable</a></span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>
Attaching package: 'tinytable'</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>The following object is masked from 'package:ggplot2':

    theme_void</code></pre>
</div>
<div class="sourceCode" id="cb134"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="va">gear</span><span class="op">)</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span></span>
<span><span class="va">cr</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span></span>
<span>    <span class="st">"hp"</span> <span class="op">=</span> <span class="st">"Horsepower"</span>,</span>
<span>    <span class="st">"factor(gear)3"</span> <span class="op">=</span> <span class="st">"3"</span>,</span>
<span>    <span class="st">"factor(gear)4"</span> <span class="op">=</span> <span class="st">"4"</span>,</span>
<span>    <span class="st">"factor(gear)5"</span> <span class="op">=</span> <span class="st">"5"</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>,</span>
<span>    include_reference <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>    coef_rename <span class="op">=</span> <span class="va">cr</span>,</span>
<span>    gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span>    <span class="fu"><a href="https://vincentarelbundock.github.io/tinytable/man/group_tt.html">group_tt</a></span><span class="op">(</span>i <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"Gears"</span> <span class="op">=</span> <span class="fl">5</span><span class="op">)</span>, indent <span class="op">=</span> <span class="fl">0</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>Warning: Argument `indent` is deprecated and will be removed in a future version. Use `style_tt("~group", indent = 1)` instead.</code></pre>
</div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_yntem3rnlipzrhhum3v6(i, j, css_id) {
          var table = document.getElementById("tinytable_yntem3rnlipzrhhum3v6");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_yntem3rnlipzrhhum3v6(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_yntem3rnlipzrhhum3v6");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () { spanCell_yntem3rnlipzrhhum3v6(5, 0, 1, 2) })
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '10', j: 1 },  ], css_id: 'tinytable_css_6q11zsmjk3kodt3dwdfe',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '8', j: 1 }, { i: '9', j: 1 },  ], css_id: 'tinytable_css_efjkyb4buz2wcf4cdefd',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_y6baq2w4s1y77ip0gliq',}, 
          { positions: [ { i: '10', j: 0 },  ], css_id: 'tinytable_css_vww3ezjehq4c12i1pfz0',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '8', j: 0 }, { i: '9', j: 0 },  ], css_id: 'tinytable_css_nvupn8ej2xx6vtbecvd2',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_ehdfl7r6prdv58j8l5w9',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_yntem3rnlipzrhhum3v6(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_6q11zsmjk3kodt3dwdfe, .table th.tinytable_css_6q11zsmjk3kodt3dwdfe { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_efjkyb4buz2wcf4cdefd, .table th.tinytable_css_efjkyb4buz2wcf4cdefd { text-align: center; }
      .table td.tinytable_css_y6baq2w4s1y77ip0gliq, .table th.tinytable_css_y6baq2w4s1y77ip0gliq { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_vww3ezjehq4c12i1pfz0, .table th.tinytable_css_vww3ezjehq4c12i1pfz0 { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_nvupn8ej2xx6vtbecvd2, .table th.tinytable_css_nvupn8ej2xx6vtbecvd2 { text-align: left; }
      .table td.tinytable_css_ehdfl7r6prdv58j8l5w9, .table th.tinytable_css_ehdfl7r6prdv58j8l5w9 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_yntem3rnlipzrhhum3v6" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)</th>
              </tr></thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">27.882</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(2.109)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Horsepower</td>
                  <td data-row="3" data-col="1">-0.067</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.011)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Gears</td>
                  <td data-row="5" data-col="1">Gears</td>
                </tr>
<tr>
<td data-row="6" data-col="0">3</td>
                  <td data-row="6" data-col="1">-</td>
                </tr>
<tr>
<td data-row="7" data-col="0">4</td>
                  <td data-row="7" data-col="1">2.635</td>
                </tr>
<tr>
<td data-row="8" data-col="0"></td>
                  <td data-row="8" data-col="1">(1.552)</td>
                </tr>
<tr>
<td data-row="9" data-col="0">5</td>
                  <td data-row="9" data-col="1">6.575</td>
                </tr>
<tr>
<td data-row="10" data-col="0"></td>
                  <td data-row="10" data-col="1">(1.643)</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
<p>Tables in other shapes may require a <code><a href="https://vincentarelbundock.github.io/tinytable/man/format_tt.html">format_tt()</a></code> call to ensure that empty cells are filled with <code>-</code>:</p>
<div class="cell">
<div class="sourceCode" id="cb136"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span>,</span>
<span>    include_reference <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>    shape <span class="op">=</span> <span class="va">term</span> <span class="op">~</span> <span class="va">statistic</span>,</span>
<span>    coef_rename <span class="op">=</span> <span class="va">cr</span>,</span>
<span>    gof_map <span class="op">=</span> <span class="cn">NA</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span>    <span class="fu"><a href="https://vincentarelbundock.github.io/tinytable/man/format_tt.html">format_tt</a></span><span class="op">(</span>replace <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"-"</span> <span class="op">=</span> <span class="st">""</span><span class="op">)</span><span class="op">)</span> <span class="op">|&gt;</span></span>
<span>    <span class="fu"><a href="https://vincentarelbundock.github.io/tinytable/man/group_tt.html">group_tt</a></span><span class="op">(</span>i <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"Gears"</span> <span class="op">=</span> <span class="fl">3</span><span class="op">)</span>, indent <span class="op">=</span> <span class="fl">0</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>Warning: Argument `indent` is deprecated and will be removed in a future version. Use `style_tt("~group", indent = 1)` instead.</code></pre>
</div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_2642k7ba2cfggdtp9gfm(i, j, css_id) {
          var table = document.getElementById("tinytable_2642k7ba2cfggdtp9gfm");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_2642k7ba2cfggdtp9gfm(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_2642k7ba2cfggdtp9gfm");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () { spanCell_2642k7ba2cfggdtp9gfm(3, 0, 1, 3) })
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '-1', j: 2 },  ], css_id: 'tinytable_css_c4n42r3wn3f7ode6b3cl',}, 
          { positions: [ { i: '6', j: 1 }, { i: '6', j: 2 },  ], css_id: 'tinytable_css_gnk1g5dz44certfxrho6',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '4', j: 1 }, { i: '5', j: 1 }, { i: '2', j: 2 }, { i: '3', j: 1 }, { i: '4', j: 2 }, { i: '1', j: 2 }, { i: '3', j: 2 }, { i: '5', j: 2 },  ], css_id: 'tinytable_css_zcv9o4iqtla4bg6uvafv',}, 
          { positions: [ { i: '-1', j: 1 },  ], css_id: 'tinytable_css_ug1tkm4h36zie7euwuje',}, 
          { positions: [ { i: '0', j: 1 }, { i: '0', j: 2 },  ], css_id: 'tinytable_css_rit63cpsxhip1c4e5kgy',}, 
          { positions: [ { i: '6', j: 0 },  ], css_id: 'tinytable_css_9phe0mnhp78ftm6so90t',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '4', j: 0 }, { i: '5', j: 0 },  ], css_id: 'tinytable_css_dsbcl6kp6nd12tomplqj',}, 
          { positions: [ { i: '-1', j: 0 },  ], css_id: 'tinytable_css_p79uxs595g8ttwdvpnuq',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_08bxwj7rnuoqgujrp7em',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_2642k7ba2cfggdtp9gfm(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_c4n42r3wn3f7ode6b3cl, .table th.tinytable_css_c4n42r3wn3f7ode6b3cl { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_gnk1g5dz44certfxrho6, .table th.tinytable_css_gnk1g5dz44certfxrho6 { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_zcv9o4iqtla4bg6uvafv, .table th.tinytable_css_zcv9o4iqtla4bg6uvafv { text-align: center; }
      .table td.tinytable_css_ug1tkm4h36zie7euwuje, .table th.tinytable_css_ug1tkm4h36zie7euwuje { text-align: center; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_rit63cpsxhip1c4e5kgy, .table th.tinytable_css_rit63cpsxhip1c4e5kgy { text-align: center; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_9phe0mnhp78ftm6so90t, .table th.tinytable_css_9phe0mnhp78ftm6so90t { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_dsbcl6kp6nd12tomplqj, .table th.tinytable_css_dsbcl6kp6nd12tomplqj { text-align: left; }
      .table td.tinytable_css_p79uxs595g8ttwdvpnuq, .table th.tinytable_css_p79uxs595g8ttwdvpnuq { text-align: left; text-align: center; border-top: solid #d3d8dc 0.1em; text-align: center; }
      .table td.tinytable_css_08bxwj7rnuoqgujrp7em, .table th.tinytable_css_08bxwj7rnuoqgujrp7em { text-align: left; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_2642k7ba2cfggdtp9gfm" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead>
<tr>
<th scope="col" align="center" colspan="1" data-row="-1" data-col="0"> </th>
<th scope="col" align="center" colspan="2" data-row="-1" data-col="1">(1)</th>
</tr>
<tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">Est.</th>
                <th scope="col" data-row="0" data-col="2">S.E.</th>
              </tr>
</thead>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">27.882</td>
                  <td data-row="1" data-col="2">2.109</td>
                </tr>
<tr>
<td data-row="2" data-col="0">Horsepower</td>
                  <td data-row="2" data-col="1">-0.067</td>
                  <td data-row="2" data-col="2">0.011</td>
                </tr>
<tr>
<td data-row="3" data-col="0">Gears</td>
                  <td data-row="3" data-col="1">Gears</td>
                  <td data-row="3" data-col="2">Gears</td>
                </tr>
<tr>
<td data-row="4" data-col="0">3</td>
                  <td data-row="4" data-col="1">-</td>
                  <td data-row="4" data-col="2">-</td>
                </tr>
<tr>
<td data-row="5" data-col="0">4</td>
                  <td data-row="5" data-col="1">2.635</td>
                  <td data-row="5" data-col="2">1.552</td>
                </tr>
<tr>
<td data-row="6" data-col="0">5</td>
                  <td data-row="6" data-col="1">6.575</td>
                  <td data-row="6" data-col="2">1.643</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>
</section><section id="footnotes-in-column-names" class="level2"><h2 class="anchored" data-anchor-id="footnotes-in-column-names">Footnotes in column names</h2>
<p>To add footnotes in column names, you can modify the <code>notes</code> slot of your <code>tinytable</code> object:</p>
<div class="cell">
<div class="sourceCode" id="cb138"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://vincentarelbundock.github.io/tinytable/">tinytable</a></span><span class="op">)</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://modelsummary.com">modelsummary</a></span><span class="op">)</span></span>
<span></span>
<span><span class="va">mod</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/lm.html">lm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">qsec</span>, <span class="va">mtcars</span><span class="op">)</span></span>
<span><span class="va">tab</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://modelsummary.com/man/modelsummary.html">modelsummary</a></span><span class="op">(</span><span class="va">mod</span><span class="op">)</span></span>
<span><span class="va">tab</span><span class="op">@</span><span class="va">notes</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span><span class="st">"a"</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>i <span class="op">=</span> <span class="fl">0</span>, j <span class="op">=</span> <span class="fl">2</span>, text <span class="op">=</span> <span class="st">"Hello world"</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="va">tab</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<!-- preamble start -->

    <script>

      function styleCell_diw6jiwxnnp2dfi6zuxf(i, j, css_id) {
          var table = document.getElementById("tinytable_diw6jiwxnnp2dfi6zuxf");
          var cell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
          if (cell) {
              console.log(`Styling cell at (${i}, ${j}) with class ${css_id}`);
              cell.classList.add(css_id);
          } else {
              console.warn(`Cell at (${i}, ${j}) not found.`);
          }
      }
      function spanCell_diw6jiwxnnp2dfi6zuxf(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable_diw6jiwxnnp2dfi6zuxf");
        const targetCell = table.querySelector(`[data-row="${i}"][data-col="${j}"]`);
        if (!targetCell) {
          console.warn(`Cell at (${i}, ${j}) not found.`);
        }

        // Get all cells that need to be removed
        const cellsToRemove = [];
        for (let r = 0; r < rowspan; r++) {
          for (let c = 0; c < colspan; c++) {
            if (r === 0 && c === 0) continue; // Skip the target cell
            const cell = table.querySelector(`[data-row="${i + r}"][data-col="${j + c}"]`);
            if (cell) {
              cellsToRemove.push(cell);
            }
          }
        }

        // Remove all cells
        cellsToRemove.forEach(cell => cell.remove());

        // Set rowspan and colspan of the target cell if it exists
        if (targetCell) {
          targetCell.rowSpan = rowspan;
          targetCell.colSpan = colspan;
        }
      }
      // tinytable span after
      window.addEventListener('load', function () {
          var cellsToStyle = [
            // tinytable style arrays after
          { positions: [ { i: '12', j: 1 },  ], css_id: 'tinytable_css_a0fl0unpnczxbnu37qsf',}, 
          { positions: [ { i: '4', j: 1 },  ], css_id: 'tinytable_css_w4278enkn2r0txafwx14',}, 
          { positions: [ { i: '1', j: 1 }, { i: '2', j: 1 }, { i: '3', j: 1 }, { i: '8', j: 1 }, { i: '5', j: 1 }, { i: '6', j: 1 }, { i: '7', j: 1 }, { i: '9', j: 1 }, { i: '10', j: 1 }, { i: '11', j: 1 },  ], css_id: 'tinytable_css_y3a2y79l8i4z1fd1tpot',}, 
          { positions: [ { i: '0', j: 1 },  ], css_id: 'tinytable_css_bs22084sxbfowr90cf0x',}, 
          { positions: [ { i: '12', j: 0 },  ], css_id: 'tinytable_css_ga2y8fk7qoy9f053b4bs',}, 
          { positions: [ { i: '4', j: 0 },  ], css_id: 'tinytable_css_7hkg78l5kgepsqw6kwoc',}, 
          { positions: [ { i: '1', j: 0 }, { i: '2', j: 0 }, { i: '3', j: 0 }, { i: '8', j: 0 }, { i: '5', j: 0 }, { i: '6', j: 0 }, { i: '7', j: 0 }, { i: '9', j: 0 }, { i: '10', j: 0 }, { i: '11', j: 0 },  ], css_id: 'tinytable_css_t269ixad3wfd8cxn05yp',}, 
          { positions: [ { i: '0', j: 0 },  ], css_id: 'tinytable_css_xn9aqahmryfnat1bh708',}, 
          ];

          // Loop over the arrays to style the cells
          cellsToStyle.forEach(function (group) {
              group.positions.forEach(function (cell) {
                  styleCell_diw6jiwxnnp2dfi6zuxf(cell.i, cell.j, group.css_id);
              });
          });
      });
    </script><style>
      /* tinytable css entries after */
      .table td.tinytable_css_a0fl0unpnczxbnu37qsf, .table th.tinytable_css_a0fl0unpnczxbnu37qsf { text-align: center; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_w4278enkn2r0txafwx14, .table th.tinytable_css_w4278enkn2r0txafwx14 { text-align: center; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_y3a2y79l8i4z1fd1tpot, .table th.tinytable_css_y3a2y79l8i4z1fd1tpot { text-align: center; }
      .table td.tinytable_css_bs22084sxbfowr90cf0x, .table th.tinytable_css_bs22084sxbfowr90cf0x { text-align: center; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
      .table td.tinytable_css_ga2y8fk7qoy9f053b4bs, .table th.tinytable_css_ga2y8fk7qoy9f053b4bs { text-align: left; border-bottom: solid #d3d8dc 0.1em; }
      .table td.tinytable_css_7hkg78l5kgepsqw6kwoc, .table th.tinytable_css_7hkg78l5kgepsqw6kwoc { text-align: left; border-bottom: solid black 0.05em; }
      .table td.tinytable_css_t269ixad3wfd8cxn05yp, .table th.tinytable_css_t269ixad3wfd8cxn05yp { text-align: left; }
      .table td.tinytable_css_xn9aqahmryfnat1bh708, .table th.tinytable_css_xn9aqahmryfnat1bh708 { text-align: left; border-top: solid #d3d8dc 0.1em; border-bottom: solid #d3d8dc 0.05em; }
    </style>
<div class="container">
      <table class="table table-borderless" id="tinytable_diw6jiwxnnp2dfi6zuxf" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing="true">
<thead><tr>
<th scope="col" data-row="0" data-col="0"> </th>
                <th scope="col" data-row="0" data-col="1">(1)<sup>a</sup>
</th>
              </tr></thead>
<tfoot><tr><td colspan="2">
<sup>a</sup> Hello world</td></tr></tfoot>
<tbody>
<tr>
<td data-row="1" data-col="0">(Intercept)</td>
                  <td data-row="1" data-col="1">-5.114</td>
                </tr>
<tr>
<td data-row="2" data-col="0"></td>
                  <td data-row="2" data-col="1">(10.030)</td>
                </tr>
<tr>
<td data-row="3" data-col="0">qsec</td>
                  <td data-row="3" data-col="1">1.412</td>
                </tr>
<tr>
<td data-row="4" data-col="0"></td>
                  <td data-row="4" data-col="1">(0.559)</td>
                </tr>
<tr>
<td data-row="5" data-col="0">Num.Obs.</td>
                  <td data-row="5" data-col="1">32</td>
                </tr>
<tr>
<td data-row="6" data-col="0">R2</td>
                  <td data-row="6" data-col="1">0.175</td>
                </tr>
<tr>
<td data-row="7" data-col="0">R2 Adj.</td>
                  <td data-row="7" data-col="1">0.148</td>
                </tr>
<tr>
<td data-row="8" data-col="0">AIC</td>
                  <td data-row="8" data-col="1">204.6</td>
                </tr>
<tr>
<td data-row="9" data-col="0">BIC</td>
                  <td data-row="9" data-col="1">209.0</td>
                </tr>
<tr>
<td data-row="10" data-col="0">Log.Lik.</td>
                  <td data-row="10" data-col="1">-99.294</td>
                </tr>
<tr>
<td data-row="11" data-col="0">F</td>
                  <td data-row="11" data-col="1">6.377</td>
                </tr>
<tr>
<td data-row="12" data-col="0">RMSE</td>
                  <td data-row="12" data-col="1">5.39</td>
                </tr>
</tbody>
</table>
</div>
<!-- hack to avoid NA insertion in last line -->
</div>
</div>


</section></section></main><!-- /main --><script id="quarto-html-after-body" type="application/javascript">
  window.document.addEventListener("DOMContentLoaded", function (event) {
    const icon = "";
    const anchorJS = new window.AnchorJS();
    anchorJS.options = {
      placement: 'right',
      icon: icon
    };
    anchorJS.add('.anchored');
    const isCodeAnnotation = (el) => {
      for (const clz of el.classList) {
        if (clz.startsWith('code-annotation-')) {                     
          return true;
        }
      }
      return false;
    }
    const onCopySuccess = function(e) {
      // button target
      const button = e.trigger;
      // don't keep focus
      button.blur();
      // flash "checked"
      button.classList.add('code-copy-button-checked');
      var currentTitle = button.getAttribute("title");
      button.setAttribute("title", "Copied!");
      let tooltip;
      if (window.bootstrap) {
        button.setAttribute("data-bs-toggle", "tooltip");
        button.setAttribute("data-bs-placement", "left");
        button.setAttribute("data-bs-title", "Copied!");
        tooltip = new bootstrap.Tooltip(button, 
          { trigger: "manual", 
            customClass: "code-copy-button-tooltip",
            offset: [0, -8]});
        tooltip.show();    
      }
      setTimeout(function() {
        if (tooltip) {
          tooltip.hide();
          button.removeAttribute("data-bs-title");
          button.removeAttribute("data-bs-toggle");
          button.removeAttribute("data-bs-placement");
        }
        button.setAttribute("title", currentTitle);
        button.classList.remove('code-copy-button-checked');
      }, 1000);
      // clear code selection
      e.clearSelection();
    }
    const getTextToCopy = function(trigger) {
        const codeEl = trigger.previousElementSibling.cloneNode(true);
        for (const childEl of codeEl.children) {
          if (isCodeAnnotation(childEl)) {
            childEl.remove();
          }
        }
        return codeEl.innerText;
    }
    const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
      text: getTextToCopy
    });
    clipboard.on('success', onCopySuccess);
    if (window.document.getElementById('quarto-embedded-source-code-modal')) {
      const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
        text: getTextToCopy,
        container: window.document.getElementById('quarto-embedded-source-code-modal')
      });
      clipboardModal.on('success', onCopySuccess);
    }
      var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
      var mailtoRegex = new RegExp(/^mailto:/);
        var filterRegex = new RegExp('/' + window.location.host + '/');
      var isInternal = (href) => {
          return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
      }
      // Inspect non-navigation links and adorn them if external
     var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)');
      for (var i=0; i<links.length; i++) {
        const link = links[i];
        if (!isInternal(link.href)) {
          // undo the damage that might have been done by quarto-nav.js in the case of
          // links that we want to consider external
          if (link.dataset.originalHref !== undefined) {
            link.href = link.dataset.originalHref;
          }
        }
      }
    function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
      const config = {
        allowHTML: true,
        maxWidth: 500,
        delay: 100,
        arrow: false,
        appendTo: function(el) {
            return el.parentElement;
        },
        interactive: true,
        interactiveBorder: 10,
        theme: 'quarto',
        placement: 'bottom-start',
      };
      if (contentFn) {
        config.content = contentFn;
      }
      if (onTriggerFn) {
        config.onTrigger = onTriggerFn;
      }
      if (onUntriggerFn) {
        config.onUntrigger = onUntriggerFn;
      }
      window.tippy(el, config); 
    }
    const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
    for (var i=0; i<noterefs.length; i++) {
      const ref = noterefs[i];
      tippyHover(ref, function() {
        // use id or data attribute instead here
        let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
        try { href = new URL(href).hash; } catch {}
        const id = href.replace(/^#\/?/, "");
        const note = window.document.getElementById(id);
        if (note) {
          return note.innerHTML;
        } else {
          return "";
        }
      });
    }
    const xrefs = window.document.querySelectorAll('a.quarto-xref');
    const processXRef = (id, note) => {
      // Strip column container classes
      const stripColumnClz = (el) => {
        el.classList.remove("page-full", "page-columns");
        if (el.children) {
          for (const child of el.children) {
            stripColumnClz(child);
          }
        }
      }
      stripColumnClz(note)
      if (id === null || id.startsWith('sec-')) {
        // Special case sections, only their first couple elements
        const container = document.createElement("div");
        if (note.children && note.children.length > 2) {
          container.appendChild(note.children[0].cloneNode(true));
          for (let i = 1; i < note.children.length; i++) {
            const child = note.children[i];
            if (child.tagName === "P" && child.innerText === "") {
              continue;
            } else {
              container.appendChild(child.cloneNode(true));
              break;
            }
          }
          if (window.Quarto?.typesetMath) {
            window.Quarto.typesetMath(container);
          }
          return container.innerHTML
        } else {
          if (window.Quarto?.typesetMath) {
            window.Quarto.typesetMath(note);
          }
          return note.innerHTML;
        }
      } else {
        // Remove any anchor links if they are present
        const anchorLink = note.querySelector('a.anchorjs-link');
        if (anchorLink) {
          anchorLink.remove();
        }
        if (window.Quarto?.typesetMath) {
          window.Quarto.typesetMath(note);
        }
        if (note.classList.contains("callout")) {
          return note.outerHTML;
        } else {
          return note.innerHTML;
        }
      }
    }
    for (var i=0; i<xrefs.length; i++) {
      const xref = xrefs[i];
      tippyHover(xref, undefined, function(instance) {
        instance.disable();
        let url = xref.getAttribute('href');
        let hash = undefined; 
        if (url.startsWith('#')) {
          hash = url;
        } else {
          try { hash = new URL(url).hash; } catch {}
        }
        if (hash) {
          const id = hash.replace(/^#\/?/, "");
          const note = window.document.getElementById(id);
          if (note !== null) {
            try {
              const html = processXRef(id, note.cloneNode(true));
              instance.setContent(html);
            } finally {
              instance.enable();
              instance.show();
            }
          } else {
            // See if we can fetch this
            fetch(url.split('#')[0])
            .then(res => res.text())
            .then(html => {
              const parser = new DOMParser();
              const htmlDoc = parser.parseFromString(html, "text/html");
              const note = htmlDoc.getElementById(id);
              if (note !== null) {
                const html = processXRef(id, note);
                instance.setContent(html);
              } 
            }).finally(() => {
              instance.enable();
              instance.show();
            });
          }
        } else {
          // See if we can fetch a full url (with no hash to target)
          // This is a special case and we should probably do some content thinning / targeting
          fetch(url)
          .then(res => res.text())
          .then(html => {
            const parser = new DOMParser();
            const htmlDoc = parser.parseFromString(html, "text/html");
            const note = htmlDoc.querySelector('main.content');
            if (note !== null) {
              // This should only happen for chapter cross references
              // (since there is no id in the URL)
              // remove the first header
              if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
                note.children[0].remove();
              }
              const html = processXRef(null, note);
              instance.setContent(html);
            } 
          }).finally(() => {
            instance.enable();
            instance.show();
          });
        }
      }, function(instance) {
      });
    }
        let selectedAnnoteEl;
        const selectorForAnnotation = ( cell, annotation) => {
          let cellAttr = 'data-code-cell="' + cell + '"';
          let lineAttr = 'data-code-annotation="' +  annotation + '"';
          const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
          return selector;
        }
        const selectCodeLines = (annoteEl) => {
          const doc = window.document;
          const targetCell = annoteEl.getAttribute("data-target-cell");
          const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
          const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
          const lines = annoteSpan.getAttribute("data-code-lines").split(",");
          const lineIds = lines.map((line) => {
            return targetCell + "-" + line;
          })
          let top = null;
          let height = null;
          let parent = null;
          if (lineIds.length > 0) {
              //compute the position of the single el (top and bottom and make a div)
              const el = window.document.getElementById(lineIds[0]);
              top = el.offsetTop;
              height = el.offsetHeight;
              parent = el.parentElement.parentElement;
            if (lineIds.length > 1) {
              const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
              const bottom = lastEl.offsetTop + lastEl.offsetHeight;
              height = bottom - top;
            }
            if (top !== null && height !== null && parent !== null) {
              // cook up a div (if necessary) and position it 
              let div = window.document.getElementById("code-annotation-line-highlight");
              if (div === null) {
                div = window.document.createElement("div");
                div.setAttribute("id", "code-annotation-line-highlight");
                div.style.position = 'absolute';
                parent.appendChild(div);
              }
              div.style.top = top - 2 + "px";
              div.style.height = height + 4 + "px";
              div.style.left = 0;
              let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
              if (gutterDiv === null) {
                gutterDiv = window.document.createElement("div");
                gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
                gutterDiv.style.position = 'absolute';
                const codeCell = window.document.getElementById(targetCell);
                const gutter = codeCell.querySelector('.code-annotation-gutter');
                gutter.appendChild(gutterDiv);
              }
              gutterDiv.style.top = top - 2 + "px";
              gutterDiv.style.height = height + 4 + "px";
            }
            selectedAnnoteEl = annoteEl;
          }
        };
        const unselectCodeLines = () => {
          const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
          elementsIds.forEach((elId) => {
            const div = window.document.getElementById(elId);
            if (div) {
              div.remove();
            }
          });
          selectedAnnoteEl = undefined;
        };
          // Handle positioning of the toggle
      window.addEventListener(
        "resize",
        throttle(() => {
          elRect = undefined;
          if (selectedAnnoteEl) {
            selectCodeLines(selectedAnnoteEl);
          }
        }, 10)
      );
      function throttle(fn, ms) {
      let throttle = false;
      let timer;
        return (...args) => {
          if(!throttle) { // first call gets through
              fn.apply(this, args);
              throttle = true;
          } else { // all the others get throttled
              if(timer) clearTimeout(timer); // cancel #2
              timer = setTimeout(() => {
                fn.apply(this, args);
                timer = throttle = false;
              }, ms);
          }
        };
      }
        // Attach click handler to the DT
        const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
        for (const annoteDlNode of annoteDls) {
          annoteDlNode.addEventListener('click', (event) => {
            const clickedEl = event.target;
            if (clickedEl !== selectedAnnoteEl) {
              unselectCodeLines();
              const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
              if (activeEl) {
                activeEl.classList.remove('code-annotation-active');
              }
              selectCodeLines(clickedEl);
              clickedEl.classList.add('code-annotation-active');
            } else {
              // Unselect the line
              unselectCodeLines();
              clickedEl.classList.remove('code-annotation-active');
            }
          });
        }
    const findCites = (el) => {
      const parentEl = el.parentElement;
      if (parentEl) {
        const cites = parentEl.dataset.cites;
        if (cites) {
          return {
            el,
            cites: cites.split(' ')
          };
        } else {
          return findCites(el.parentElement)
        }
      } else {
        return undefined;
      }
    };
    var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
    for (var i=0; i<bibliorefs.length; i++) {
      const ref = bibliorefs[i];
      const citeInfo = findCites(ref);
      if (citeInfo) {
        tippyHover(citeInfo.el, function() {
          var popup = window.document.createElement('div');
          citeInfo.cites.forEach(function(cite) {
            var citeDiv = window.document.createElement('div');
            citeDiv.classList.add('hanging-indent');
            citeDiv.classList.add('csl-entry');
            var biblioDiv = window.document.getElementById('ref-' + cite);
            if (biblioDiv) {
              citeDiv.innerHTML = biblioDiv.innerHTML;
            }
            popup.appendChild(citeDiv);
          });
          return popup.innerHTML;
        });
      }
    }
  });
  </script><nav class="page-navigation"><div class="nav-page nav-page-previous">
      <a href="../vignettes/datasummary.html" class="pagination-link" aria-label="Data Summaries">
        <i class="bi bi-arrow-left-short"></i> <span class="nav-page-text">Data Summaries</span>
      </a>          
  </div>
  <div class="nav-page nav-page-next">
      <a href="../vignettes/modelplot.html" class="pagination-link" aria-label="Model Plots">
        <span class="nav-page-text">Model Plots</span> <i class="bi bi-arrow-right-short"></i>
      </a>
  </div>
</nav>
</div> <!-- /content -->



</body></html>